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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.