View Full Version : Easy Image Gallery
roxics
10-13-2002, 07:27 AM
It's just an idea and I don't know how possible it is but...
So you have a forum with a list of threads. Those threads are labled with titles (text). You go into the thread and there is a picture that was attached using the "attach file" option. The board is set to display that picture. Hey great people can see the picture and comment on it too.
Now what if instead of having the text title the system automatically created a thumbnail of that picture to diplay in the thread view.
Now when you go to that forum there is a list of thumbnails going down the screen instead of thread titles. Click on the thumbnail and it takes you to that post where the picture shows up.
Hey now that forum is an image gallery. :)
What do you think? Can anyone do it? Is it possible?
Dmitriy
10-13-2002, 11:52 PM
This would require installing some type of image manipulation software on the server, either GD, or image magic (probably the best choice) or gimp, but sure, this can be done.
Eander
10-14-2002, 12:21 AM
Originally posted by Dmitriy
This would require installing some type of image manipulation software on the server, either GD, or image magic (probably the best choice) or gimp, but sure, this can be done.
Nah, you wouldn't need that stuff. I'll work on this and post something up.
Ok so I lied. You will need GD. However, most versions of PHP nowadays come with it already. If you don't have it, beg your host to install it.
You need to find this near line 630 in forumdisplay.php:
eval("\$forumdisplaybits .= \"".gettemplate('forumdisplaybit')."\";");
And right before it put this:
if ($forumid==xxxxx) {
$checkquery=$DB_site->query_first("SELECT postid FROM post WHERE threadid=$thread[threadid] and username='$thread[postusername]' ORDER BY dateline ASC");
$avurl="http://www.yourdomainhere.com/forums/attachment.php?postid=" . $checkquery['postid'];
$sizes = getimagesize($avurl);
if ($sizes) {
$newwidth=$sizes[0];
$newheight=$sizes[1];
if ($sizes[0] > 100) {
$newwidth=100;
$diff=$sizes[0]-100;
$rat=100/$sizes[0];
$newheight=$sizes[1]*$rat;
}
$imagethumb="<img src=\"./attachment.php?postid=" . $checkquery['postid'] . "\" width=" . $newwidth . " height=" . $newheight . "><br>";
}
}
Replace xxxxx with the forumid that you wish to have set as an image gallery. Replace http://www.yourdomainhere.com/forums/ with the path to your vbulletin directory.
The last thing you'll need to do is edit your forumdisplay template finding this string:
<td bgcolor="{firstaltcolor}" align="left" width="70%"><normalfont>$thread[gotonew] $paperclip$thread[movedprefix]$thread[typeprefix]<a href="showthread.php?s=$session[sessionhash]&threadid=$thread[threadid]">$thread[title]</a></normalfont> <smallfont>$thread[pagenav]</smallfont></td>
and changing it to this (changes underlined)
<td bgcolor="{firstaltcolor}" align="left" width="70%"><normalfont>$imagethumb $thread[gotonew] $paperclip$thread[movedprefix]$thread[typeprefix]<a href="showthread.php?s=$session[sessionhash]&threadid=$thread[threadid]">$thread[title]</a></normalfont> <smallfont>$thread[pagenav]</smallfont></td>
That should do it. Hope this is what you wanted. Also, I made it so if the first person that posts doesn't attach an image it doesn't try to show a thumbnail. Enjoy!
roxics
10-15-2002, 08:55 AM
Thanks for doing this. Unfortunately for me it doesn't seem to work.
http://ve.roxics.com/board/forumdisplay.php?s=&forumid=11
Is it because there is no GD installed on the server? How would I know? What is GD exactly?
BTW where you said you have to change the "forumdisplay" template it's actually the "forumdisplaybit" template.
roxics
10-15-2002, 09:05 AM
Also just out of curiousity, would there be a way to make it work with multiple forums to have multiple galleries?
Eander
10-15-2002, 10:22 PM
Originally posted by roxics
Thanks for doing this. Unfortunately for me it doesn't seem to work.
http://ve.roxics.com/board/forumdisplay.php?s=&forumid=11
Is it because there is no GD installed on the server? How would I know? What is GD exactly?
BTW where you said you have to change the "forumdisplay" template it's actually the "forumdisplaybit" template.
Yeah, the only thing that I could see for it not to be working would be that you don't have GD installed. As you can see in the php, if $sizes isn't defined it won't declare the $imagethumb variable that is called for in the template. The only reason for $sizes not to be set is if you don't have GD. The only real way I can think of is try making a php file with just <? phpinfo(); ?> and see if it says anything about GD being installed. If it doesn't, look for the version of PHP you're running, and if need be upgrade to the newest version. If all else fails contact your host, asking if they have the GD module of PHP installed. Hope this helps. :\
Dmitriy
10-15-2002, 11:11 PM
Question for Eander: even if the PHP has a GD support, what if the GD support only comes with libpng? Whould it still be able to re-size the gif and jpeg images?
I don't think GD has any support for GIF at all.
Eander
10-16-2002, 10:15 PM
GD isn't actually resizing it. All it's doing is getting the sizes by the getimagesize() command, then adding a width="xxx" height="xxx" parameter to the <img> tag. It's all IE doing the resizing, but the numbers it is resized to are determined by GD.
Dmitriy
10-17-2002, 12:52 AM
I see
Well, you don't need GD to have the getimagesize function to work. In fact, this function is used in several files in vbulleting.
If you just change the height and width attributes of the image, it's not the same as re-sizing the image itself.
Also, in order to do what was originally requested in this tread, you must create thumbnail images at the same time an image is uploaded and store them somewhere separately, you can't just create thumnail images in real-time, it will take too much time.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.