Jump to content

Help with Timthumb and custom thumbnails?


Herra

Recommended Posts

Hello, I have a file upload site for my IRC channel, and I'm using timthumb to generate thumbnails.

 

The problem is, I allow users to upload other than image files and they obviously show as blank now on my website.

 

Any ideas how I could show custom made thumbnails for files such as .rar?

 

i.e. user uploads a rar file, and my site instead trying to do this:

<div class='tiedosto'><a href='up/rss.rar' class='tiedosto screenshot' rel='up/rss.rar' ><img src='thumb.php?src=up/rss.rar&h=100&w=100&zc=1' alt=''></a></div>

it would show this

<div class='tiedosto'><a href='up/rss.rar' class='tiedosto screenshot' rel='up/rss.rar' ><img src='thumb.php?src=thumb/rar.png&h=100&w=100&zc=1' alt=''></a></div>

or just

<div class='tiedosto'><a href='up/rss.rar' class='tiedosto screenshot' rel='up/rss.rar' ><img src='thumb/rar.png'></a></div>

 

Thanks.

would have to first find out what the file extension is, and if not an image, use some image you created

 

$filename = "up/rss.rar";
$image_source = $filename;
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$images_ext = array("jpeg","jpg","png","gif","bmp","tiff");//add or remove as needed
if(!in_array($ext, $images_ext)){
$image_source = "/images/default-$ext.png";//create a default image for each file type
//$image_source = "/images/default-image.png";//a general image for all
}

 

so now when you display your code, place the $filename and $image_source into it something like this.

<div class='tiedosto'><a href='<?php echo $filename;?>' class='tiedosto screenshot' rel='<?php echo $filename;?>' ><img src='thumb.php?src=<?php echo $image_source;?>&h=100&w=100&zc=1' alt=''></a></div>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.