Mod Name / Version - Image Gallery v1.0 Description - Turns a selected forum into a picture gallery allowing permitted groups to post and comment on uploaded images. Uses existing attachment features and file size limits. Example - http://www.newoutriders.org/ubbtest/postlist.php?Cat=&Board=gallery Pre-requisites - none Author - Aglavalin, aka Steve Stout Files Altered - showflat.php, showflat.tmpl, showthreaded.php, showthreaded.tmpl Database Altered - no New Files - none Note: Use group permissions on forum(s) to determine who can post. Any other info - this is a simple hack
Here is my first real hack. It turns a forum into a basic image gallery which could be pulled into an IIP page very easily. It allows users to comment on the images as well. This took me a few days to figure out, and it seems to be working fine. The only thing I could not figure out was how to check if the attachment was an image before displaying it. Perhaps someone could clue me in on how to do this?
I just added instructions to upgrade the newspal.php file in IIP 4.3 to display the images from the image gallery, such as use on a homepage or whatnot.
Optional code to make images show up in the newspal.php file with IIP 4.3
As per only trying to insert it if the file is an image. There was an old hack like this one... I'm using it on my board... except that I've got it set to all boards.
I haven't tested this.... but here's the code that checks if it's a .jpg or .gif ....
So maybe you need something like this:
code:
if ($File) { $File = rawurlencode($File); $postrow[$i]['filelink'] = "<a href="{$config['fileurl']}/$File">{$ubbt_lang['FILE_ATTACH']}</a>";
//--------------------------- //image gallery addon if ($Board == "FORUM_NAME" and (eregi("\.GIF|\.JPG|\.PNG", $File))) { $postrow[$i]['showfile'] = "<center><img src="{$config['fileurl']}/$File"></center><br><br>"; } }
Again.... haven't tested this... I'm not a PHP expert and don't know if I've got the syntex of an if statement with an "AND" correct or now.... but the old hack that JustDave wrote for 5.5 used "if (eregi("\.GIF|\.JPG|\.PNG", $File))" to check if it was a GIF, JPG or PNG file.
Just a small thought, you could modify the code that inserts the disk image on the postlist to show an image that indicates the posts includes an image instead?
From what I could see on his board that hack was already installed. But what I meant was to extend that hack to show an icon describing an image (like a canvas, a palette or something) instead of the diskette icon when applicable.
The reason I thought of this was that he had two test threads, one with an included image and one with a text file attached. From the postlist, both showed a diskette icon, which made it seem like both had an image inside it. That is, since that particular forum should be an image gallery. Of course, if only posts with images are posted in the forum it won't really matter, the disk would mean that the post has an image in it. But still, something showing an image would be better IMHO.
Yeah I had a post with a text file for testing purposes. This seperate image for a graphic attachment seems like it should be added onto the attachment image hack to me. Maybe I'll add this to my board, gotta think about it first
Yes, I guess that would be the best place to put it. Maybe it could be expanded to recognize archives, text files etc, and show different pictures depending on what it is.
I was just thinking about doing a revision to the attachment image hack to make a distinction for .zip files, graphics, .txt and my board posts alot of video clips..... it would be cool with a logo to indicate video files.
I'll get to work.
I wonder how all this will work with 6.1 since there is that download script? I wonder if that will get in the way of this type of stuff?
The filename of the file should still be in the database, so it's just a matter of reading that. I don't think there will be any problems, you will probably need to change the code a bit though.
Has anyone had any issues using this hack? It seems pretty stable to me and I'll move it to finished status if no problems are reported. I'm planning on updating it if needed for the 6.1 version after I install a copy.
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.