Generate thumbnails
Permalink
Hi everyone!
There is a lot of added images.
I have created a type of block (gallery)
When installing it creates thumbnail type.
But this thubnail type images is not created.
Question: how to programmaticaly generate image thumbnails after create thumbnail type?
There is a lot of added images.
I have created a type of block (gallery)
When installing it creates thumbnail type.
But this thubnail type images is not created.
Question: how to programmaticaly generate image thumbnails after create thumbnail type?
Hi antonovsky,
There is an add-on that might serve as an example of how to programmatically rescan thumbnails:
"Rescan All Files"
https://www.concrete5.org/marketplace/addons/rescan-all-files...
In the File Manager "Rescan" bulk action the rescan() method is called using AJAX:
/ccm/system/file/rescan
Concrete\Controller\Backend\File::rescan
https://github.com/concrete5/concrete5/blob/develop/concrete/control...
There is also a rescanThumbnails() method:
concrete\src\File\Version.php
I agree with jordif that rescanning all thumbnails might causes issues. Especially with low memory shared hosts. Rescanning only files used might be a useful approach
There is also an issue on GitHub proposing a way to conditionally create thumbnails for blocks and add-ons. Please comment the issue if you are also interested.
"Conditional thumbnails #3559"
https://github.com/concrete5/concrete5/issues/3559...
There is an add-on that might serve as an example of how to programmatically rescan thumbnails:
"Rescan All Files"
https://www.concrete5.org/marketplace/addons/rescan-all-files...
In the File Manager "Rescan" bulk action the rescan() method is called using AJAX:
/ccm/system/file/rescan
Concrete\Controller\Backend\File::rescan
https://github.com/concrete5/concrete5/blob/develop/concrete/control...
There is also a rescanThumbnails() method:
concrete\src\File\Version.php
I agree with jordif that rescanning all thumbnails might causes issues. Especially with low memory shared hosts. Rescanning only files used might be a useful approach
There is also an issue on GitHub proposing a way to conditionally create thumbnails for blocks and add-ons. Please comment the issue if you are also interested.
"Conditional thumbnails #3559"
https://github.com/concrete5/concrete5/issues/3559...
I think there are 2 separate issues here:
1) Is the new thumbnail type created? If you go to Dashboard -> System & Settings -> Files -> Thumbnails, is the new thumbnail type listed there?
2) If the new thumbnail type is there, next you need to rescan all uploaded images. You can do so by going to Dashboard -> Files, select the items and under "Items Selected" choose "Rescan".
Not sure if it's possible to programmatically regenerate all thumbnails. Not sure if it's a good idea either. Are you planning to upload your gallery to the marketplace? If so, maybe you could explain in the documentation how to rescan the thumbnails manually, so users can decide what images need to be rescanned (forcing the rescan programmatically could be both resource-intensive and error-prone, imagine a website with thousands of images)
Jordi