single_page & thumbnail
Permalink 1 user found helpful
I have a package with several single_page pages.
Within one of the pages I wish to display the thumbnail of an asset from the library.
I have the fID of the asset... how do I (or indeed can I) use that to retrieve the thumbnail..?
Within one of the pages I wish to display the thumbnail of an asset from the library.
I have the fID of the asset... how do I (or indeed can I) use that to retrieve the thumbnail..?
Thats great remo... and it does work... however... this only works for images and I need to display a thumbnail regardless of file type just like in the asset manager where zip files show a zip icon thumbnail.
I could do it by parsing the file extension and having icons to hand as part of my package but it seems C5 is able to do this itself.
I guess what I'm really after is the thumbnail associated with the asset identified by fID
Do you know of a way to do this from a single page given the fID...?
I could do it by parsing the file extension and having icons to hand as part of my package but it seems C5 is able to do this itself.
I guess what I'm really after is the thumbnail associated with the asset identified by fID
Do you know of a way to do this from a single page given the fID...?
ah I see. That should be possible too. You have to work on the FileVersion object though.
There's a method called getThumbnail. I've seen the first paramter set to 1 and 2. You can also check if there's a generate thumbnail by using hasThumbnail
Try to start by calling "getVersion" on your file object.. There you should find everything you need
There's a method called getThumbnail. I've seen the first paramter set to 1 and 2. You can also check if there's a generate thumbnail by using hasThumbnail
Try to start by calling "getVersion" on your file object.. There you should find everything you need
maybe something from here?
http://svn.concrete5.org/svn/concrete5/trunk/web/concrete/helpers/i...
http://svn.concrete5.org/svn/concrete5/trunk/web/concrete/helpers/i...
public function getThumbnail($obj, $maxWidth, $maxHeight) { if ($obj instanceof File) { $path = $obj->getPath(); } else { $path = $obj; } $fh = Loader::helper('file'); if (file_exists($path)) { $filename = md5($path . ':' . $maxWidth . ':' . $maxHeight . ':' . filemtime($path)) . '.' . $fh->getExtension($path); } else { $filename = md5($path . ':' . $maxWidth . ':' . $maxHeight . ':') . $fh->getExtension($path); } if (!file_exists(DIR_FILES_CACHE . '/' . $filename)) { // create image there $this->create($path, DIR_FILES_CACHE . '/' . $filename, $maxWidth, $maxHeight);
Viewing 15 lines of 27 lines. View entire code block.
Cheers Remo...
This was my solution...
This was my solution...
$f = File::getByID(fID); $fv = $f->getApprovedVersion(); $src = $fv->getThumbnail(1);