php - How to Generate Thumbnails in Laravel5.2 When I display image -
when write code display image in blade file time image thumbnails made , can give every time height,width time need image kind of image thumbnails generates can generate multiple thumb of same image in single site.
{{$page->image,100,100)}}
or
<td><?php if ($page->image) { ?><img src="{{ url('/upload/pages/'.$page->image,100,200) }}"/><?php } ?></td>
please give suggestion how make kind of thumbnails in advance.
a rational way be:
create controller , method (or method on existing controller) accepts image name, width & height parameters. method use intervention package mentioned in comments. logic should - first check if image of specified dimensions exists, if doesn't - create (using intervention, simple). - output image contents (don't forget add correct header).
add controller/method routes.php, eg:
route::get('thumbnails/{image}', 'controller@getthumbnail');
in blade templates refer images '/path/image.jpg?width=200&height=100'. no need care whether file these dimensions exists or not.
ps. facebook serves images way. it's little proxy server (your method works proxy) between user , original image.
Comments
Post a Comment