September 21, 2008

Fixing WordPress fGallery plugin

Filed under: Blog — krkhan @ 9:22 pm

For the past two years, I have been using Fredrick Fahlstad’s fGallery plugin for managing images in my WordPress blog. Unfortunately, this excellent piece of software was left unmaintained with the last stable release taking place way back in 2006. For a while now, I’ve had my gripes with some of the things in fGallery. The two options I had were to either (A) fix what was broken or to (B) use another plugin from WordPress Extend.

(B) seemed like too much trouble so I decided to go for the former option and get my hands wet with PHP again. Here’s a list of stuff that I modified in the original 2.4.1 release:

  • Fixed output of special HTML characters in album and image titles to conform with XHTML standards.
  • Modified to send HTTP response “Status:200 OK” back to the client in fim_photos.php. Without this, all of my fGallery pages were returning 404 error code for nice URLs even though they were working in the browser.
  • Fixed an SQL injection vulnerability in fim_rss.php.
  • Fixed image order on album pages and RSS feeds. Without using the table name in the ORDER queries, images were being returned in random order.
  • Fixed date issues in album RSS feeds.
  • Images are now shown in their original sizes in case their width is smaller than 600 pixels. In case they overflow this limit, they are shown in a 600 pixels wide frame with an option to click them for viewing in original size. This was to prevent larger image from messing up blog themes.

Here’s a diff file with the mentioned changes, which should be applied to the 2.4.1 release. I’ve also uploaded a modified zip archive for convenience of those who don’t have access to the patch command.

Tags: , , , , , , , , ,


  1. Hey pal,

    I’m the developer of fGallery and I can now say that I have taken up development and maintenance of my plugins.

    Comment by Fredrik Fahlstad — September 21, 2008 @ 10:25 pm

  2. Fredrik, that’s good news :-) Hope to see a new version of fGallery soon. Thanks for the plugin.

    Comment by krkhan — September 21, 2008 @ 11:25 pm

  3. Do you know if the SQL insert statement that fGallery uses works with the new version (2.6.2) of wordpress? When I try and install fGallery, with your updates, it’s not creating the database tables. Also, when I try and upload any pictures or create an album, I get the error that it can’t create the album or add the image to the database.

    I think it’s got something to do with the SQL insert statement, but I haven’t looked at the code in so long, I’m not 100% where to start or what to change.

    Thanks for the help!

    Comment by Kyle — September 26, 2008 @ 4:42 am

  4. I got it working. For some reason, post version 2.1 and the plugin couldn’t create the database tables it needed.

    I found the fix here:

    Comment by Kyle — September 26, 2008 @ 5:57 am

  5. […] ago I had to code a few fixes for the fGallery WordPress plugin. The patch was released as version 2.4.1-1 and it wasn’t until yesterday that I noticed the “Previous” and […]

    Pingback by Rough patches | Inspirated — February 17, 2009 @ 3:20 pm

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.