working with concrete/blocks/library_file/controller.php
Permalink
Hi, trying to get a thumbnail to come back out of this inside the current image block, but I am stumped as to where to start. I have checked out the video block for a little guidance and peered into the library_file/controller to see what it is doing, but I just can't seem to get it to output the thumbnail. I am relatively new to php and I wanted to learn this on my own as a learning experience, but 6 hours today is about when I decide to throw in the towel and ask for a little guidance :)
Thank you in advance.
-Scott Conrad
Thank you in advance.
-Scott Conrad
If you download the latest release, 5.1, we've actually simplified this stuff a bit, and made it much more powerful. You can create thumbnails programmatically on the fly of whatever dimensions you like (the aspect ratio of the source image will be preserved.) So, let's see you wanted to modify the image block template so that, instead of just showing the image, you showed a thumbnail image that was no larger than 300x300, and it linked to the original image.
This is the code that accomplishes just that:
The first line gets the file object from the image block. This represents the image object that is saved with the image block when you save it (the first one you select.) The second line starts printing the link. The third line outputs a thumbnail no larger than 200x200 pixels. If the thumbnail does not exist at that size, a version of it will be created and saved in the cache directory. Finally the fourth line finishes the link.
Like I mentioned - this is only available in 5.1 - it was added at the last minute. But if you use the file objects whenever you're building your own blocks, you should have a lot of flexibility as to how you can display thumbnails.