Laravel-filemanager: How to get the thumbs path of uploaded image.

Created on 26 Jul 2017  路  4Comments  路  Source: UniSharp/laravel-filemanager

I have uploaded image successfully,and can access it.How can i get the path of the thumnail image ?
Do i need manually append "thumb" in file path to retrieve it ? or is any other way workaround for this ?
Like
File path : /uploads/shares/test/1410463802_fcity.png
Thumb : /uploads/shares/test/thumbs/1410463802_fcity.png

enhancement

Most helpful comment

Yup,i did it using creating a helper function,and appending a thumb in the image path.
This is what i did.

```
static function getThumb($path)
{
$str_to_insert = '/thumbs';
$oldstr = $path;
$pos = strrpos($path,"/");

     return substr_replace($oldstr, $str_to_insert, $pos, 0);
}

```
Definitely you people can do this in more efficient way.

All 4 comments

@asimshazad Yes, you should append "thumbs" to get thumbnail's path. We can only return one path, original image or thumbnail, at a time. Would you suggest how we can enhance this feature in the future?

Yup,i did it using creating a helper function,and appending a thumb in the image path.
This is what i did.

```
static function getThumb($path)
{
$str_to_insert = '/thumbs';
$oldstr = $path;
$pos = strrpos($path,"/");

     return substr_replace($oldstr, $str_to_insert, $pos, 0);
}

```
Definitely you people can do this in more efficient way.

Implemented in v2.0.0-alpha6. This feature can be accomplished by change the callback in stand-alone-button.js.

@streamtw @tsawler is it implemented in version 1.9.2 and could you provide an example on how to approach this ?

$lfm_helper = new \UniSharp\LaravelFilemanager\Traits\LfmHelpers();
$full_file_path = $category->banner;
$thumb_url = $lfm_helper->getThumbUrl($full_file_path);

i have tried the above code and i'm getting

ErrorException (E_ERROR)
Cannot instantiate trait UniSharp\LaravelFilemanager\Traits\LfmHelpers

i guess it would be great if it can be accomplished using this in blade file :
{{ $getThumburl($category->banner) }}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DaxtonChen picture DaxtonChen  路  4Comments

farshidahmadianpin picture farshidahmadianpin  路  3Comments

lunadiotic picture lunadiotic  路  3Comments

sanvu88 picture sanvu88  路  3Comments

ikkosatrio picture ikkosatrio  路  4Comments