Reputation: 97
Hi I'm trying to get thumbnails with the same TimThumbs, I'm using Intervention Image and Intervention Cache.
My thumbnails now have the url structure:
thumbs/122x88?src=upload/news/news_40942c468090384b8135a6bbb79f631d.png
How do I get an address like:
/thumbs/upload/news/122x88-news_40942c468090384b8135a6bbb79f631d.png
I would like to remove this "?src="?
My route code is as follows:
Route::get('thumbs/{imgw}x{imgh}/', function ($imgw,$imgh)
{
$src = \Input::get('src', 1);
$width = $imgw;
$height = $imgh;
$cacheimage = \Image::cache(function($image) use ($src,$width,$height) {
return $image->make($src)->resize($width,$height);
}, 1, false);
return Response::make($cacheimage, 200, array('Content-Type' => 'image/jpeg'));
});
I tried to remove "\Input::get"
, but It's not working.
Upvotes: 0
Views: 1204
Reputation: 104
Check it out how I get the pictures on my website: https://www.verhuisdieren.nl/
So on imagecache.php ( config file ), i just setup the route for all the images ( lets say 'route' => 'images' ), and when I upload images, I upload them on the storage folder and rename them before I save them. From Laravel 5.3 you can save it with the FileUploader class like this:
$request->get('image')->save('new-name');
and this then loads it without any prefix.
So recap: don't make a route for it, you already have that on your imagecache.php file. You can then get the route something like this:
url(config('imagecache.route'), ['YOUR-SIZE', 'FILENAME']);
EDITED:
config file example ( the config file imagecache.php ):
Upvotes: 1