2016-11-19 27 views
2

我正在使用dropzone在Laravel上載圖像。縮略圖底部的顯示文件名稱

有什麼方法可以在縮略圖的底部顯示圖像名稱?

我知道圖像名稱將在懸停到縮略圖時顯示,但我希望顯示縮略圖底部的文件名而不會懸停在縮略圖上。

代碼如下。

我的dropzone js在我的上傳頁面中。

Dropzone.options.imageUpload = { 
    paramName: "image", // The name that will be used to transfer the file 
    maxFilesize: 30, // MB 
    uploadMultiple: true, 
    clickable: true, 
    maxThumbnailFilesize: 30, 
    parallelUploads: 1, 
    maxFiles: 10, 
    dictMaxFilesExceeded: "This image is exceeded the limit upload", 
    init: function() { 
    this.on("queuecomplete", function(file) { $("#buttons").show(); }); 
    }, 
    accept: function(file, done) { 
    if (file.name == "justinbieber.jpg") { 
     done("Naha, you don't."); 
    } 
    else { done(); } 
    } 
}; 

我上傳的控制器

$User = Auth::user()->id; 
    $category = Category::active()->first(); 
    $sizeHeight = Size::orderBy('height', 'ASC')->where('status', 0)->first(); 
    $sizeWidth = Size::orderBy('width', 'ASC')->where('status', 0)->first(); 
    $files = $request->file('image'); 

    if(!empty($files)): 
     $urls = array(); 
     foreach($files as $val => $file): 
      $now = Carbon::now(); 
      $time = str_replace(':', '-', $now); 
      //$number = $val + 1; 

      echo $sizeHeight; 
      echo $sizeWidth; 
      $filename = $file->getClientOriginalName(); 
      //get image size 
      $filepath = $file->getRealPath(); 
      list($width, $height) = getimagesize($filepath); 
      //if wrong orientation then 

      if($width >= $sizeWidth->width || $height >= $sizeHeight->height) 
      { 
       // Ryan 22 October 2016 (Saturday) move save photo to top 
       $photo = new photo; 
       $photo->user_id = $User; 
       $photo->photoName = $time . $filename; 
       $photo->category_id = $category->id; 
       $photo->subcategory_id = "1"; 
       $photo->name = null; 
       $photo->keyword = null; 
       $photo->status = "2"; 
       $photo->save(); 

      } 
    endif; 

這是我目前的結果,當我徘徊在縮略圖

enter image description here

,我希望它是這樣的,而不徘徊。

enter image description here

請幫助。

+0

請添加一些代碼...... –

+0

請分享您的代碼... –

+0

@MinalChauhan我已經更新了我的代碼 –

回答

0

如果你想添加文字到圖片,你可以使用Image Intervention軟件包的Laravel。 text()方法將幫助你。

在可選的x,y基點位置處將文本字符串寫入當前圖像。您可以定義更多細節,如字體大小,字體文件和通過回調對齊作爲第四個參數。

如果您只是想在圖像上顯示一些文字而不編輯文件,那麼您可以使用use CSS

+0

我不想將文本添加到我的照片。我只想在我的dropzone縮略圖的底部顯示我的文件名 –