Creating an image gallery for phpBB
January 27, 2009 at 3:37 pm | In Blog, Website Development | 6 CommentsTags: architecture, avatar, bbcode, coppermine, emoticon, extension, firefox, forum, free, gif, host, image, jpg, php, phpbb, png, refactor, rss, thumbnail, website
As part of the dirtmind site I wanted to provide a gallery for users to uploads pics, emoticons etc. for posting in the dirtmind forum and so we could start building some content. With the general philosophy of don’t pay for things when there’s so much great open source about I looked at the Coppermine image gallery. Ok, so there’s some not so great open source about too. All of the galleries I looked at were ok, but didn’t integrate deeply into my site (which was now based on the phpBB architecture) so I set about (armed with no php skill but a bit of general programming skills) to write my own.
Key Features
- Users can upload images into their sfw or nsfw galleries
- Users can delete images they’ve uploaded
- Site admins can delete other people’s images
- Very large images are automatically scaled down
- Images are tagged intelligently (large image get a big tag, medium images get a smaller less obtrusive tag, tiny images get no tag at all so that thinks like emoticons or avatars can be uploaded)
- Images should be exposed as RSS so that latest uploads can be shown
- JPG, GIFÂ and PNG (static, transparent and animated) to be supported
- Thumbnails are automatically created
- Multiple files can be uploaded at once
- BBCode is automatically generated for both single images and multiple selection
The Gallery
Should be fairly easy right? Actually, it was fairly easy – there’s a lot out there on how to upload files, watermark and resize images so it was quite straightforward to manage the uploading into user directories. At first I thought “I don’t need a database” since I was using a user and gallery based directory structure to store the files. This was mind numbingly stupid as it caused performance issues once the image number got large and made things like images RSS very hard to do.
So I bit the bullet and refactored the gallery into using a database to record images. This was actually pretty simple and didn’t affect my code much, I do a DB insert when an image is uploaded, a DB delete when it’s removed and then there’s just a bunch of selects instead of directory scanning.
I’m really happy with the multiple file upload capability, this was based on the stick man’s idea of making multiple file uploads look like they’re using a single file input element. Once uploaded the files are presented back to the user as a grid of thumbnails which can then be selected/unselected and with each change in selection the BBCode is automatically generated using javascript. Good stuff
Of course since all the pages on my site are in the phpBB architecture I’ve got things like login, user rights etc. done for me but even so the result is I think an extremely clean and elegant image host – it’s got none of the complexity that the old Coppermine System used to have galleries are automatically created for users when they upload their first image. Due to the tight integration into the forum software it’s incredibly simple to post uploaded images (single or multiple) into the forum, in fact it’s a single click!
You can checkout the gallery here including the bbcode generation features but you can’t upload images unless you’ve registered an account (this is to prevent abuses and spam) but registering is free like everything else at DirtMind so feel free to register and upload some images if you want to try it out.
Related to this I’ve also launched a FireFox Extension for BBCode to make BBCode as simple as right clicking on images and links
What is DirtMind?
January 27, 2009 at 11:58 am | In Blog, Website Development | Leave a CommentTags: entertainment, forum, free, games, host, image, news, uk
DirtMind is my hobby, a free (not even any ads) website that provides:
- An entertainment and news portal (UK focussed but including some international content)
- A free image host supporting static images, animations that applies intelligent tagging (small images don’t get a tag)
- A chat forum to provide a place to comment on whatever you want in a very loosely moderated environment
- A selection of extremely good and addictive online games
This blog is about the experiences behind creating and maintaining DirtMind. You may well ask why the DirtMind blog isn’t hosted on DirtMind.com? The answer is because wordpress.com is awesome and everything is done for me here
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.