I have been looking for a simple plugin for WordPress that just displays photos that I upload. I got tired of trying out things like Gallery2 integration and stuff like that. I just wanted a simple photo gallery. No extra text, no comments, nothing. Just a photo gallery.
So, I created it myself since I couldn’t find an easy one.
Thanks to the new WP 2.0 structure for uploads generating folders by year and month, it’s nicely categorized too. Now, I’m sure there’s tons of ways to enhance/change this plugin to work better with different themes, better output, and probably faster code. But, for the sake of failing fast, I’ve decided to release it as is.
Known Issues: Yes, there is an inherent problem with using the wp-content/uploads folder in that there’s no way to distinguish between a graphic you uploaded for a post and a photo you wanted to share. The idea behind this plugin is to decipher this problem with a minimum width and height. So, there are two optional variables to the plugin when you write the code in your page; minimum height and minimum width. By default they are set to 300 pixels each. This means that if an image’s height and width are above 300 pixels, we will consider that an image you wanted to display in the photo gallery. Additionally, when the photo is displayed as enlarged, we set it by default to a width of 450 pixels wide to hopefully fit it into most themes. If you need to modify this, you can do so within the function call.
If you use it, I’d love it if you either commented or did a trackback here so I can see your implementation of it.
If you modify it, I would love to know. I would be happy to take your modifications in and re-release it with your name in the credits if the modifications are general enough to fit most everyone’s themes and needs.
Enough of the chitter chatter. Here it is: duh-gallery.zip (please go to the wiki to download it or discuss any issues with it from here on. I am not abandoning the project, just moving it to a more community supported location. Thanks!)
Requirements: You’ll need Exec-PHP or some other plugin that will allow you to write PHP into your posts/pages. You’ll also need to make sure you have WP 2.0+. Last, if you have modified the location of your uploads folder, you’ll need to change the location in the plugin.
1) Extract the zip file.
2) Upload the duh-gallery.php file to your plugins directory (usually wp-content/plugins).
3) Activate it in the Plugins admin panel.
4) Write a new Page. Put the following PHP code inside the page (you may have to turn off the visual rich editor before entering this code by going to Users and unchecking the box “use visual rich editor” at the bottom):
<?php do_action('duh_gallery'); ?>
Optionally, you can specify the enlarged display width and the minimum width and height to be considered a photo in this gallery like this (450 is the width to display enlarged images at, 100 is the min-width an image needs to be to be shown in the gallery and 150 is the min-height an image needs to be to be shown in the gallery):
<?php do_action('duh_gallery', 450, 100, 150); ?>
5) Voila, you have a photo gallery.
Demo: You can see a demo of the output on my “Photos” page.
Donate to Charity: I didn’t realize how popular this would get so quickly. So, since plugins are generally free, I’d like to ask for your support to help some charities I know needs it. One in particular is called Giving Anonymously, which is just getting started. It’s mission is to foster generosity one-to-one. If you use this plugin and care to donate to a cause such as this, please do so here. (The company name will be called Property Essentials, which is my company name. But you’ll have to trust me that I’ll give the money to Giving Anonymously. Sorry, I don’t have another way around that right now.):
Credit: I have to give credit where it’s due. Thanks Robert, for the help on building my first plugin. This guy is a genius.
UPDATE v0.1.2: I updated the plugin already so that it displays thumbnails instead of full images resized down.
UPDATE v0.1.3: Another quick update added the Previous/Next links to enlarged icons for navigation.
UPDATE v0.1.4: Added support for blogs that don’t use nice permalink structure.
UPDATE v0.1.5: Added better sorting (rsort) for both files and folders.
UPDATE v0.1.6: Fixed the PHP5 construct problem and the negligable p tag shown in certain circumstances.
UPDATE v0.1.7: Fixed the T_ELSE bug
From this point on, any new updates are located on the wiki.
Please see the wiki discussion if you need any help as well.
Update: A brainstorm session has been started for another WordPress plugin over here. I’d love your remarks, please.
Update: I just wrote a new post on some great WordPress Themes and Plugins for Photography. You might want to check that one out too, while you’re at it since this post is somewhat old now.
[tags]wp, wordpress, photo, gallery, plugin, duh gallery[/tags]