PDf Thumbnail

Permalink
Hi:
I am building a website that have a downloadable file list. Each file(image) has a thumbnail.
But the PDF does not have a thumbnail.

I made a image/file file attribute so i can manually put the thumbnail.
Does anyone knows how i can get that attribute and output the attribute URL

fjhadd
 
jero replied on at Permalink Reply
jero
I'm not sure you can have an image/file attribute attached to a file. Do you mean perhaps that you've added a text attribute instead, or have you added the attribute to a page? Please explain in more detail.
fjhadd replied on at Permalink Reply
fjhadd
Well if you go to System & Settings > Attributes > Types and check File in the image/file row you can use this kind of attribute on files.


I just dont know how to output in a block
jero replied on at Permalink Best Answer Reply
jero
Oh, right. OK, well assuming you know the ID of the file that you're working with, you could try this:

$fID=42; // file id
$att='my_attribute'; // attribute handle
$fo=File::getByID($fID); // get the file object
$at=$fo->getAttribute($att); //get the attribute, which returns another file object.


Then you can get the url, height and width like this
echo $at->getURL();
echo $at->getAttribute('height');
echo $at->getAttribute('width');


or if you need to generate a thumbnail of say, 50px square:

$ih=Loader::helper('image');
$thumb = $ih->getThumbnail($at, 50, 50);
echo $thumb->src;
echo $thumb->height;
echo $thumb->width;
rrcustom replied on at Permalink Reply
Did you get this working? I need to do something similar with a different file type.
fjhadd replied on at Permalink Reply
fjhadd
Yes try to follow Jero post.
Go to System & Settingd > Attributes > type and check File in the image/file row.
Then add a file attribute using image/file attribute type.

And manually add the thumbs