Herra Posted December 1, 2011 Share Posted December 1, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/252244-help-with-timthumb-and-custom-thumbnails/ Share on other sites More sharing options...
QuickOldCar Posted December 2, 2011 Share Posted December 2, 2011 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> Quote Link to comment https://forums.phpfreaks.com/topic/252244-help-with-timthumb-and-custom-thumbnails/#findComment-1293292 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.