This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
A method to generate thumbs from images in the media library would be really nice. Like this:
MediaLibrary::thumb($pathToImage, $width, $height, $mode, $customOutputPath = null)
+1, its quite easy to write your own plugin but i feel like it should be in the core already since image attachments got this
It doesn't really matter for me. Let me think about it. But spontaneously my suggestion would be a folder in storage/temp
This would be really handy! I'm sure a lot of people have a large image (A featured image for a blog post, for example), and also need to show a thumbnail version throughout the site.
daftspunk said:
Just to clarify, where would you expect the thumbnail to be created on the filesystem?
Maybe
storage/app/media/.thumb/-----------.jpg
Just to throw out a possibility. Another CMS I use implements a system using defined 'transforms'. The transform includes title, handle, mode (crop, fit, or stretch), crop-position (top-left, top-center, top-right, etc.), height, width (either of which can be blank to autosize the missing dimension), quality setting (low, medium, high, very high, maximum), and image format (auto, jpg, gif, png). Named transforms can then be used to auto-generate transformed images at runtime using twig: <img src="{{ image.getUrl('thumb') }}" width="{{ image.getWidth('thumb') }}" height="{{ image.getHeight('thumb') }}">
Transforms can also be defined in the twig template dynamically:
{% set thumb = {mode: 'crop', width: 200, height: 200, quality: 75, position: 'top-center'} %}
Transformed images are stored in a folder named after the transform (i.e. storage/app/media/_thumb).
Last updated
I made a plugin for something like this which is currently awaiting approval. You can find it here, if you want to try it: https://github.com/manogi/october-mediathumb
Thanks! The plugin is now an official octobercms plugin: http://octobercms.com/plugin/manogi-mediathumb
If its any help, I wrote a plugin recently to accomplish this - https://octobercms.com/plugin/toughdeveloper-imageresizer
It supports cropping out of the box, works with images anywhere on the filesystem, caches images and doesn't require any additional dependencies.
1-14 of 14