Search code examples
laraveluploadlaravel-bladelaravel-8unisharp-file-manager

unisharp laravel-filemanager Thumbnail url


Hi I'm using unisharp laravel-filemanager for user to upload their products photos

when the image uploaded

this address will save in database

/photos/44/606074649c651.jpg

and I can use it by

{{asset('storage/'.$product->cover_img)}}

and Thumbnail saved in this address

/photos/44/thumbs/606074649c651.jpg

How can I get the address of thumbnail and how can I use it in blade?

This is the answer

@php($lastSlash = strrpos($product->cover_img,"/"))

src="{{asset('storage/'.substr_replace($product->cover_img, 'thumbs/', $lastSlash+1) .'' .substr($product->cover_img ,$lastSlash+1))}}"

Solution

  • One way to save it in the database is to add a hidden type input to the image's thumb, inside the stand-alon-button.js file.

    // set or change the preview image src

    items.forEach(function (item) {
          target_preview.append(
             $('<img>').css('height', '5rem').attr('src', item.thumb_url),
             $('<input type="hidden" name="thumbnail">').attr('value', item.thumb_url)
          );
       });
    

    Input:

    <div class="input-group">
        <span class="input-group-btn">
            <a id="lfm" data-input="thumbnail" data-preview="holder" class="btn btn-primary">
               <i class="fa fa-picture-o"></i> Choose
            </a>
             </span>
             <input id="thumbnail" class="form-control" type="text" name="image">
    </div>
    <div id="holder" style="margin-top:15px;max-height:100px;"></div>
    

    enter image description here enter image description here enter image description here