Duh Gallery: The Simple WordPress Photo Gallery Plugin

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.):

to Giving Anonymously

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]

Nate Ritter lives in Austin, Texas (U.S.), popularized the #hashtag and creates web applications for a living. He also does miles and point hacking to enable cheap travel for his family. More here →

130 Comments on "Duh Gallery: The Simple WordPress Photo Gallery Plugin"

  1. Hi Nate

    I know I have tracked back I also just wanted to pop in and say brilliant. Thanks for the plugin – it works very simply and very well.

    By the way, are you a Christian?


  2. Hi Nate

    Having read your site quite a bit more I feel the question in the last comment rather superfluous!

    God bless and I’m praying that God will continue to use your talents because He most certainly is at the moment. This site is a blessing.


  3. nate says:

    I’d love to know how you would like it customized. I’ll post a comment on your site too. Thanks for the trackback!

    Thanks for the comment and trackback. I appreciate the feedback. And yes, I am a Christian.

  4. nate says:

    Update 0.1.3
    I’ve updated the plugin once more, adding the use of WP generated thumbnails (to save bandwidth) in 0.1.2 and the Previous/Next links for navigation when you have an enlarged photo.

  5. nate says:

    I noticed a problem with sites that don’t use nice permalinks. I’ll fix that next.

  6. nate says:

    Update 0.1.4
    Added support for not-nice permalink structures.

    And… Illumination Church also has an implementation of it.

    So does Cregy.

    If you have an implementation of it, please feel free to add a comment here and show us (as long as it’s not obscene photos).

  7. looks simple and good enough for blogs that have few pics.
    Good work!

  8. Brian says:

    So, do I need to put the PHP code everytime I want to show a gallery of photos. Is there a way to make it automatic when you uplaod a file?

  9. Brian says:

    Sorry, I forgot to put my email address.

  10. nate says:


    The easiest way to do it is download the PHP-Exec plugin first (see the link above), and activate that. Then, write a Page (not a Post), and put the PHP code inside that page. Then it’s automatic and it will show any photo you upload automatically.

  11. Rick says:

    Parse error: parse error, unexpected T_ELSE in /home/carwashs/public_html/wp-content/plugins/duh-gallery.php on line 139

    When I activate it it blows up the site with this bit information. I have waited for a simple gallery for quite a while and was hoping this was it.

    I must be doing something wrong but I did as your install info asked and uploaded the single php file duh-gallery.php file and poof. I noticed another file as well tried that in addition as well with the same result.

    Thanks Rick

  12. nate says:

    Yea, sorry Rick. I received this email from Tony, who said he fixed it. I’m not exactly sure why this works for him. But, here you go:

    Hey man, I fixed it. I edited your main comment. I removed the “?>” in “Just paste < ?php do_action('duh_gallery'); ?> into the page you want to use as your photo album… ” My page was reading it at the end of the PHP script, instead of reading it at part of your comment. Once I removed it, uploaded it, it worked great.

  13. Rick says:

    Now thats fast tech help! I will give it try thanks very much Nate. Everybody should notice the time stamp on the postings you can’t better then that.

  14. nate says:

    What can I say, I love my “clients”. :) Call me a fanatic. BTW, if you need hosting, I’m just as fanatical about my hosting clients too. The design of the site sucks and is very outdated, but I like to spend my time with my clients and doing other things that matter more.

    Thanks for your support Rick, make sure to let me know if that helped.

  15. Rick says:

    Well it was a nice try but that didn’t work. It still blows up upon activation. Same thing as before. I removed the entire just paste code as well. It’s commented out properly but to no avail. Anymore ideas?

  16. nate says:

    *Note* I’m emailing you now to see if there’s a better way I can help you via IM and/or taking a look at your site a little closer. I want to make sure we figure this thing out as I haven’t been able to see the problem on my own sites yet.

  17. Brian says:

    Hey thanks Nate, I will try that!

  18. Joel says:

    I have border to my thumb !!! Did I have to modify the php ??


  19. nate says:

    The borders and layout can be set in your stylesheet (CSS). If you need help with that, let me know. I will need the URL you’re testing it at.

  20. Joel says:

    this is the url


    Did I have to modify in the css the :



    a:active ?


  21. nate says:


    You can use the following CSS inside your style.css file. Put it in the Main Body at the end of that section:

    #duh_gallery_photos img {
    border: 0;

    That will give you no border to your photos. If you want a space between them, you can add “margin: 2px;” in there if you’d like.

  22. Joel says:

    Thanks very much

    work well !!!

  23. Jan says:

    Hi Nate
    Have tried your plugin. Running it on a wp 2.0.2 installation with no modifications made, gives me the following error:

    Warning: opendir(/hsphere/local/home/srjma/news.consits.dk/wp-content/uploads): failed to open dir: No such file or directory in /hsphere/local/home/srjma/news.consits.dk/wp-content/plugins/duh-gallery.php on line 142

    Warning: readdir(): supplied argument is not a valid Directory resource in /hsphere/local/home/srjma/news.consits.dk/wp-content/plugins/duh-gallery.php on line 143

    Warning: closedir(): supplied argument is not a valid Directory resource in /hsphere/local/home/srjma/news.consits.dk/wp-content/plugins/duh-gallery.php on line 155

    Current Location:

  24. nate says:

    Hi Jan,

    I wonder if your upload directory is not already setup. My guess is that it’s not. You’ll want to make sure to set that up first. Here’s the steps:

    1) Go to your admin section » Options » Miscellaneous

    2) Make sure you have something like “wp-content/uploads” in the field named “Store uploads in this folder:” (Additionally, it would be good if you checkmarked the box “Organize my uploads into month- and year-based folders”

    3) You need to go to that directory (wp-content/uploads) via some FTP program (probably the same way you installed the plugin) and change the permissions to 777. How exactly you do that depends on the FTP program. But, essentially you need to make sure the owner, group and everyone can read, write, and execute in that directory.

    Once you have all that setup properly, or if you have trouble doing that, let me know. I’d be happy to take a closer look.

  25. Ant says:

    Hi Nate,

    Thanks for making this – looks like it might be exactly what I’m after.

    I’m using version 0.1.2 on wordpress 2.0.2. I’ve modified it to point at a different folder, and it seems to work fine except it only shows four of the images in there. I haven’t set a minimum size for display. Bit confused. Any ideas?

  26. nate says:

    Hi Ant,

    It defaults to only showing images that are greater than 300 pixels wide and 300 pixels high. So, if the images you are using are smaller than that, you’ll want to set the height/width to something else.

    Also, I’d suggest getting 0.1.4, but I understand if you’ve mod’d an older version. You can see what updates have been done to the newer versions above.

  27. Ant says:

    Thanks, I’ll mod that 300 minimum out.

    A bit confused about the version. I only downloaded it today, using your link above to the zip file, which I would have thought would be pointed at the latest version. Have double checked though and I definitely have v 0.1.2. Does your link need updating?

  28. nate says:

    Yea, the option is there so that you can say something like 1px wide and 1px high. That would pretty much give you anything without having to mod the plugin. :)

    Ah! Yes, I think I forgot to change the versioning on the plugin. Dang. Nice catch. Thanks.

  29. Hi Nate

    I had to go looking and found a whole load of photos in 2003/08. So can you tell me which one is you!


    P.S. Hope you had an awesome Sunday!

  30. Tony A. says:

    Nate already mentioned this in an earlier post, but he wanted me to post as well. I was receiving, “Parse error: parse error, unexpected T_ELSE in /home/chasaarn/public_html/
    guybearinit/wp-content/plugins/duh-gallery.php on line 109″.

    My problem was corrected when I noticed in my editor that the PHP script was being read incorrectly due to a PHP script example in the main comment. I removed the ending tag “?>” from “Just paste <?php do_action(‘duh_gallery’); >” Uploaded the edited version and the gallery is working fine.

    Other that the above, I followed the installation instructions given by Nate on the site.

    Sorry for the delay in posting, I had a busy weekend.

    Thanks guys,

  31. nate says:

    Rich, I’m the one sleeping with the cat.

    Tony, thanks for adding that to the list. :)

  32. Hi Nate

    Thanks for that. Of course now I want to know who is the more adorable!?!

    Answers on a postcard to…..


  33. Hi Nate

    A couple of things. If you take a look at:
    You’ll see I have now added several more galleries. But the styling doesn’t look so good.
    I have tried this:
    #duh_gallery_photos a:link {
    display: block;
    #duh_gallery_photos img {
    border: 0;
    margin: 2px;
    .attachment {
    display: inline;
    Any ideas please?
    And I also thought you would be interested in the pictures about Jesus.



  34. nate says:


    It might look better if you removed the “a:link” and the “.attachment” elements and just left the “#duh_gallery_photos img”

  35. Hi Nate, I just can’t get the gallery to work, i’m using worpdress 2.2.1 and whenever I add the code to a post, with or without the visual editor it still just displays it as text, I do also have phpEXC activate, so I have no idea what is going on.
    I also tried to make a page with the template photos and added the code into that, however I get nothing?

    The one in the actual page is here: http://billytheradponi.pandela.org/photos-test/

    And the one with the template here: http://billytheradponi.pandela.org/photos-test-2/

    Thanks in advance,

  36. nate says:

    Hmm.. It looks to me like the Exec-PHP plugin isn’t working. Did you just download it? I’d try something else, like

    <?php do_action('duh_gallery'); ?>

    If that doesn’t work, then it has to be the Exec-PHP plugin. I’m not sure why it would do that – but let me know if it is. Perhaps I can help you more with your blog or ftp credentials. If so, feel free to email me.

  37. Yeah I tried that, it didn’t work and my Exec-PHP plugin should be fine, Ill re-install it as a test though

  38. nate says:

    oh shoot… I meant to say try something like

    <?php echo 'hey there'; ?>

    If it prints out the code, then Exec-PHP isn’t working correctly. But, if it prints out ‘hey there’, then the Exec-PHP plugin is working properly and it must be something else. Keep telling me what’s going on with it. I’ll help you as much as I can.

  39. My Exec-php was out of date and now is working however with the duh gallery code i get:

    Fatal error: Non-static method Duh_Gallery::Duh_Gallery() cannot be called statically in /usr/home/users/61/swordsnps/www/billytheradponi.pandela.org/wp-includes/functions.php on line 1279

  40. Oh and half the template doesn’t show either?

  41. nate says:

    Ah, interesting. That’s a new one. I’ll have to check that out. Sorry I don’t have an answer for you right this second. I’ll post one here as soon as I do though.

    Do you know what version of PHP your host is running?

  42. 5 i think, they might be updating it though…

  43. 5 i think, they might be updating it though…they are Pandela and I would guess they have the latest php, which is 5 I think…

  44. crb3 says:

    UPDATE v0.1.2: I updated the plugin already so that it displays thumbnails instead of full images resized down.

    Admittedly I’m new to PHP (Perl’s more my thing), so chide me gently if I’ve missed something obvious in modernday PHP’s builtins, but…

    From my reading of your code, you define a thumbnail filename and display it if it exists. If it doesn’t exist, you don’t create a new thumbnail file with that filename, instead you ship the full-sized image to the browser to be displaye within a thumbnail’s space… in which case, the update line quoted above is incomplete or misleading. In my case, 25 quarter-meg JPEGs, even over a 10base LAN, made it obvious. I’ll be looking into invoking ImageMagick’s convert to generate the thumbnails, myself, but that’s Yet Another Dependency — Your Hosting May Vary.

  45. nate says:


    Yes, you are correct. The reason I don’t have the script create the thumbnail is because theoretically WordPress should be doing that itself. However, you’ve got a point in the sense that I probably should have one created if it’s not already there.

    Good catch. I’ll add that in the next version.

  46. crb3 says:

    One hack already… Rather than having those 25 JPEGs marching way off into horizontal-scroll-land, I constrained my copy to four-per-line. Changes as follows:

    class Duh_Gallery {
    var $wcount=4; # added variable
    –x– snip
    if (empty($f)) {
    if (!empty($files)) {
    $wcount=4; # make sure it’s initialized
    –x– snip
    if (file_exists(“$dir/$str_path/$vf”)) {
    … look for thumbnail…
    …show original…
    # added code:
    if(–$wcount == 0){
    $wcount = 4;
    echo ”;
    echo ‘ ‘;
    } # after 4 pics, switch to a new paragraph.

    In my browser, the potential empty paragraph at the end (when an exact multiple of 4 pictures is in the given subdirectory) is negligible.

  47. crb3 says:

    Finishing up with the prior comment: WordPress ate the two new echoed lines, which were close-paragraph, followed by open-paragraph with class=attachment.

  48. crb3 says:

    Good catch. I’ll add that in the next version.

    Thank you. That way, your script will ship thumbnails even when the pictures are SCP’d or FTP’d into place (which is how I have things arranged), rather than uploaded through WordPress (something I admit to not having tried out).

  49. nate says:


    Yea, I fixed the empty paragraph thing, but will go after the thumbnail creation in 0.1.7

  50. Anonymous says:

    I am also have this issue:

    Fatal error: Non-static method Duh_Gallery::Duh_Gallery() cannot be called statically in C:\WebSites\blog\wp-includes\functions.php on line 1279

    I’ve read through all the posts here and on runPHP (which is the php plugin I am using, b/c I couldn’t get wordpress to even recognize exec-php

    any and all help would be appreciated

  51. nate says:

    Sorry Anon and anyone else having this problem. I’m trying to figure it out. I do know that it’s a problem with whoever is using PHP5 right now. I’m trying to track it down as we speak.

  52. Mauricio says:

    hey, thanks for the plugin it´s great, i just want to know if therre´s a way that instead of categorizing it by date, it would do it by category is that possible??

    thanks mauricio

  53. nate says:

    It would be possible if you changed how you uploaded things. The current structure is based on the default WordPress uploading methods (year/month).

  54. Here is the link to my site: Gallery. I like the plugin, but when it opens the first directory, it shows 2 image placeholders and there aren’t any images to show in that place. Any idea why that could be?

  55. nate says:

    What browser do you see those placeholders in? I’m using Firefox on a Mac and don’t see any.

    At one time, I there was a problem where it would show a placeholder in the “Files” section if there was an empty directory present. But, I believe I fixed that.

  56. I am using IE6. I tried firefox and it doesn’t show the placeholders.

    IE6 shows these placeholders.

    I suspect it will be down to empty directories. I have 2 of these in this directory.

  57. nate says:

    Ah, well, I would suggest removing those two empty directories then. I thought I fixed that issue with the latest version, but I’ll check into it again. Thanks.

  58. nuelle says:

    when I try to activate the plugin I get this error:

    Parse error: parse error in /raid/domains/org/n/nuelle/htdocs/www/wp-content/plugins/duh-gallery.php on line 149

    Warning: Cannot modify header information – headers already sent by (output started at …/htdocs/www/wp-content/plugins/duh-gallery.php:149) in …/htdocs/www/wp-admin/plugins.php on line 16

    Using: Wp 2.02
    Exec PHP 2.0

    any Ideas?

  59. nate says:

    That one is strange. I have no idea on that one. Can anyone else shed some light on this?

  60. nate says:

    That sounds like the same problem as Rick had (above), just a different line. To fix it, they he said he didn’t put the “?>” in the code that you write into the page. Let me know if that fixes it for you.

  61. simple man says:

    I have the same problem as nuelle with WordPress 2.02. Did anyone figure out the solution? Thanks!

  62. Debbie says:

    Based on your response, that would mean I have to create the page to hold the code before activating the plug-in?

    A couple of questions there:
    1) Is that the only thing you put on the page?
    2) What extension should the page’s filename be?


  63. Debbie says:


    I looked at the code and there does appear to be a stray “ELSE” statement on line 149 that’s causing this error: Parse error: syntax error, unexpected T_ELSE in /home/itgurlf/public_html/blog/wp-content/plugins/duh-gallery.php on line 149

    It breaks my entire WordPress blog site.


  64. nate says:

    Debbie, nuelle, and simple man,

    I looked at the code as well, and don’t find that stray “ELSE” anywhere. I’ve even got a working copy of it running here (WP 2.0.2).

    I wish I could fix it, and if someone has, please feel free to send me an email (nate [at] perfectspace . com) and attach your fixed copy. I’ll be happy to check out the differences and include the fixed copy here for download.

    Oh, and Debbie, there’s no extension for a page… you create the page in the wordpress system (on the menu go to Write -> Write Page) and can name it whatever you want. And yes, after you install the php-exec plugin, you just type the line as per the instructions above, that’s the only thing to put on the page.

  65. Debbie says:

    Thanks for the reply, Nate.

    I have tried everything. I upgraded my site to WordPress 2.1. I have the following environment:

    1) duh_gallery.php is in: /public_html/blog/wp-content/plugins
    2) the following directory structure exists:
    3) I created a page through WordPress and copied the code into that page. (BTW, don’t have a clue where that page ends up in the WordPress hierarchy.

    The minute I try to “activate” your plug-in I get this error:

    Parse error: syntax error, unexpected T_ELSE in /home/itgurlf/public_html/blog/wp-content/plugins/duh-gallery.php on line 149

    Also, when I “view” the new page through WordPress manage pages I actually see as if it was text on the page. I then edited the HTML to remove the tags, but no luck.

    Urgh. Frustrating. I was really looking for something simple.

  66. mr nice ash says:

    hi nate,

    i am experiencing the same as debbie’s.
    Parse error: parse error, unexpected T_ELSE in /usr/local/apache2/htdocs/mrniceash/wp-content/plugins/duh-gallery.php on line 149

    i put the plugin on my plugins folder and upon activating it, it threw the above error. i can’t even access any of my blog’s pages until i deleted the plugin.

    please help.

  67. Debbie says:

    I just noticed a post from April 6th that mentioned there’s something wrong with this from the initial comment i the duh-gallery.php:

    What should it be?

  68. mr nice ash says:

    hi again!

    i think i’ve fixed it.

    // Just check the file isn’t in the ignore array if( !in_array( $file, $ignore ) ){

    on my editor, that IF statement was written at the same line as the comment, therefore the following “ELSE” is a stray.

    please try to look at it debbie.

    another question i have is,
    Do I have to create the thumbnails manually? I ve created a folder under uploads with default images on it but I’m not able to see them on my gallery page.

    thanks in advance.

  69. nate says:

    K, i uploaded a copy where I’ve made an extra return at that line. Would you please download it and test it to see if it works?

    And if you haven’t uploaded the files using WP 2.0+, then yes, you’d have to create the thumbnails manually. They will need to have a filename like

  70. mr nice ash says:

    thanks nate.

    i’m using it now.

  71. nuelle says:

    mr nice ash might be right, although I can´t see why this happens.
    I added a few linebreaks to find that “missing or wrong” else statement but I found nothing.
    Then I uploaded the file with my linebreaks in it and I could activate the plugin.

    Hope this give you a clue.

    Thx for your effort guys.

  72. nate says:

    Thanks mr nice ash and nuelle for testing it out. I’m not sure what the deal is with that, but I’ll take another look.

    I appreciate the help in troubleshooting it. I added a reference to your site in the update to 0.1.7 comments. Thanks again.

  73. mr nice ash says:

    hi nate,

    it’s my pleasure. btw, i noticed that it takes longer to load the images when there are no thumbnails. so i guess i’d better create thumbnails.

    Q: How did this plugin sorts the folders and files displayed on the page?

  74. Debbie says:

    I downloaded the new version and was able to successfully activate. I posted two messages here last night, but the response I got was that the system thought I was a spammer. ;-)

    The only problem I have now is that I see on my page. What’s wrong with that line?

    Thanks, Deb

  75. nate says:

    Hey guys, sorry that the comments you left got caught in spam, I just found a bunch this morning and released them.

    Anyway, the plugin sorts the folders in descending order. Since it was intended to use the WP 2.0 structure (year, month, day), it sorts where the most current would come up first. I believe the files are sorted by the date/time they were uploaded in descending order too, if I remember right.

    Deb, what’s the problem? What line?

  76. nuelle says:

    finally it works for me…

    that´s pretty cool

    I had one more problem in the “showDirectory” function the
    $ignore = array( ‘.’, ‘..’, ‘cgi-bin’ );
    $dh = opendir( $directory );
    were somehow in the above comment so I had an invalid readdir() and closdir() source
    but UPDATE v0.1.7 solved it

  77. nate says:

    Awesome! Thanks to everyone for sticking through it with us and figureing this out. I appreciate it.

  78. mr nice ash says:

    where can i get the latest update?

  79. Debbie says:

    Sorry, Nate. That was a type. My new page created through the Manage Pages feature of WordPress is displaying this:

    on the page when viewed. What is wrong with the code? I also looked for the “view with richtext editor” checkbox like you mention in your instructions, but do not see that anywhere on WordPress 2.0.2 page.

  80. nuelle says:

    @ Debbie: You find this option in WordPress by the Users tab this option is stored for each profile

    lower right corner:

    Personal Options

    Use the visual rich editor when writing


  81. nate says:

    I just update the original download link with the latest version. It should be 0.1.7 right now.

    nuelle is correct about the richtext editor… thanks nuelle.

  82. mr nice ash says:

    i just downloaded 0.1.7, however, i opened it with my text editor and found out that $ignore = array( ‘.’, ‘..’, ‘cgi-bin’ ); and $dh = opendir( $directory ); falls at the same line as the comment on line 148. this causes nuelle’s problem on showDirectory function.

    if i uploaded and activated 0.1.7 without opening it first with my editor, the plugin will work fine. but once i opened it, it returns the error on showDirectory.

    this is still a possible issue for the plugin.

  83. Joel says:

    Here’s one for the suggestion box:
    Include any JPEG or IPTC captions that may appear in the image. This way the viewer can have an idea of what the picture is about. ImageMagick’s ‘identify’ or ‘rdjpgcom’ can be used to extract the comments.

  84. nate says:

    Ooh, nice one. I like that. :) Thanks Joel!

  85. nuelle says:

    nate did you find anything on the PHP5 bug Billytheradponi mentioned?

    Fatal error: Non-static method Duh_Gallery::Duh_Gallery() cannot be called statically in /usr/home/users/61/swordsnps/www/billytheradponi.pandela.org/wp-includes/functions.php on line 1279

    I have a local environment with PHP 5 and get the same error.
    When switching to PHP 4.x your script works fine.
    That is why I am happy my provider still uses PHP 4.x :)

    I would be glad if someone has any hints on this.

  86. nate says:

    mr nice ash,
    ok, that’s just strange. I have no idea why that error would come up after opening it unless your editors are setting line endings differently. I’ll double check the formatting that my editor uses and the line endings it uses, but that’s just wacky.

    I have not found the fix for the PHP5 problem yet. I’m having a friend (Robert Deaton, genius whiz kid) take a look at it to see if he can fix it since I don’t have a PHP5 environment to test anything in, and he’s the one who suggested I use that methodology in writing the plugin in the first place. I’ll let you/everyone know as soon as I have something. If anyone else figures it out first, I’d love to hear about it.

    Does anyone else think I should start using paging for the comments?

  87. nuelle says:

    Hey nate,

    I fu**ing made it :)

    simply change the code you enter in your page or post for php5:

    < ?php $gallery = new Duh_Gallery(); ?>

    instead of:

    < ?php do_action('duh_gallery'); ?>

    hope it helps, could anyone try to confirm it works?

  88. Stan says:

    I’m getting the following error when trying to activate this in the WP admin area. Any ideas? Thanks.

    Parse error: parse error, unexpected T_VARIABLE in /home/atango/public_html/blog/wp-content/plugins/duh-gallery.php on line 114

  89. nate says:

    Hi Stan,

    I’m sorry I’m unable to help you out right now. It’s been crazy trying to pack up and move these past (and next) few days. But, I’ve created a wiki for the project, and I hope that people who have been so kind as to help out in other ways will continue to do so over here at http://duhgallery.wikispaces.com/

    Once I have some time to spare, I’ll check back on your issue and if it hasn’t been solved yet, I’ll get to work on it.

    Sorry for the bad timing. I promise, we’ll get it all worked out.

  90. Jason says:

    Nice plugin!

    I think I’ve got it working correctly on our new Gallery page.

    Thanks very much!

  91. nate says:

    Awesome! I added you to the wiki Gallery.

    Thanks Jason.

  92. mr nice ash says:

    i added mine. hope you dont mind.

  93. nate says:

    Not at all, that’s what it’s there for. Thanks mr nice ash.

  94. Joe Mosca says:

    I got it running fine, but I cannot follow the Hack by CRB3 to wrap the images. I would settle to put spaces between the images and the them wrap if that would work. See


    please email modified code or detailed instructions.

    Thank you,

    Joe Mosca

  95. Debbie says:

    I’m still getting this error after creating the new page:

    Warning: readdir(): supplied argument is not a valid Directory resource in /home/itgurlf/public_html/blog/wp-content/plugins/duh-gallery.php on line 149

    Warning: closedir(): supplied argument is not a valid Directory resource in /home/itgurlf/public_html/blog/wp-content/plugins/duh-gallery.php on line 156
    Current Location:


    Edit this entry.

    ,,, end

    The “wp-content/uploads” directory is set to 777. I have photos in there dated in April, but there are no subdirectories. Should there be?

  96. mr nice ash says:

    hi debbie,

    please verify if theses lines:

    $ignore = array( ‘.’, ‘..’, ‘cgi-bin’ );
    $dh = opendir( $directory );

    were not commented. if so, uncomment them.

    hope this helps.

  97. claus hansen says:

    Having the same problems as Debbie, first with the php entry, and now with supplied arguements .. any ideas? the two lines are not commented out.

  98. gerg says:

    Seems like a great plugin… If I could get it to work. I’m having the same problem as Debbie.

    On the page where I’ve added the call, I get this:

    Warning: readdir(): supplied argument is not a valid Directory resource in /home/everyday/public_html/projects/KRLT/wordpress/wp-content/plugins/duh-gallery.php on line 149
    Warning: closedir(): supplied argument is not a valid Directory resource in /home/everyday/public_html/projects/KRLT/wordpress/wp-content/plugins/duh-gallery.php on line 156

    Current Location:

  99. Karen says:

    Hi There,
    Just thought I’d drop you a note to let you know I added my gallery to your WIKI and I’ve had no problems with it that I couldn’t fix easily.

    I did do a couple of modifications to your script though:

    added a fix to include the alt tag on thumbnails and larger images:


    also added here:

    echo '';

    because without that modification my gallery page wasn’t validating
    your anchor tags for the thumbnails had an extra slash at the end “/” so I removed the slash and I now have 0 warnings or errors in HTML Tidy.

    What I would like to see is a mod to determine how many thumbnails to show per page. Other than that it’s a great plugin…

  100. Warning: readdir(): supplied argument is not a valid Directory resource in /usr/home/pedrocarrillo0/www/wp-content/plugins/duh-gallery.php on line 150

    Warning: closedir(): supplied argument is not a valid Directory resource in /usr/home/pedrocarrillo0/www/wp-content/plugins/duh-gallery.php on line 157

    Same error than Debbie and Gerg.

    Any idea? I verified path, folders, permissions, and code commented as you said.

  101. It’s working now, I uncommente the lines:

    $ignore = array( ‘.’, ‘..’, ‘cgi-bin’ );
    $dh = opendir( $directory );


  102. Dann S. Washko says:

    Hey, this is a fantastic plug-in. I’ve noticed an issue though, but it may just be on my end. I’ve noticed if a directory contains only one image, that image will not display and the page is blank. If I add a second image to that directory then both images display on the page.

  103. nuelle says:

    Hey, I uploaded a modified version of the plugin which now creates thumbnails automatically. It also creates valid XHTML code.

    it´s to be found at the WIKI:


  104. Dann S. Washko says:

    Ok, I think I found what the problem is. I’m trying to use duh-gallery in conjunction with ImageManager. When I upload files to the directory that duh-gallery is configured to use, ImageManager creates a .thumbs directory that holds the thumbnails for the images. Duh-gallery is picking up this directory (even though I figure it should be ignored due to the $ignore=array variable on line 154).

    I noticed in safari that my gallery page had an extra link in there, a blank in Firefox, denoted by a question mark. When I deleted the .thumbs directory that mark went away and all my images in that directory displayed. I deleted all but one, displaying was no problem.

    I added .thumbs to the ignore array and that solved my problem.

  105. nate says:

    Sorry folks, comments have been disabled on this entry. Please start discussions at the wiki and use the download from there as it is now a community supported project.

Trackbacks for this post

  1. Derek Scales
  2. Ham Radio Blog
  3. WORDPRESS GOD: 300+ Tools for Running Your WordPress Blog « Alex DiggMore
  4. Мега подборочка плагинов для wordpress | Записная книжка
  5. Running Your WordPress Blog With 300+ Tools | oOrch Blog
  6. Галерея в WordPress это реально! Подборка Плагинов - Околоблог рунета
  7. Я Дизайнер! » Blog Archive » Плагины для WordPress
  8. Criar site Grátis com o WordPress | Criar Sites
  9. Wordpress Photo Gallery Themes | Nate Ritter
  10. WordPress Tools Collection | indimovi
  11. 50+plugin wprdpress media | [K]4[V]N.NET-All Keys For You!
  12. wordpress photo gallery plugin | MaNoJpArEtA.iNfO
  13. Los mejores plugins para Wordpress | TiDul
  14. 50 Excellent Image Galleries You Can Use Today « Shafaat Awan
  15. WORDPRESS GOD: 300+ Tools for Running Your WordPress Blog « © 1999 – 2009 Lololov World â„¢
  16. Compartiendo Enlaces: 36 Wordpress Plugins — Pablo del Rio
  17. Top 300 Tools To Supercharge Your WordPress Blog » Noast
  18. Brainstorm: WordPress Event Plugin
  19. WordPress Plugins for Images, Photographs, and Graphics
  20. Photoblogs and Galleries with WordPress - Wordpress Arena
  21. 30 Free Resources for Photoblogging and Image Galleries (Wordpress)
  22. Servicios Web Gratis » 10 Plugins WordPress para imagenes
  23. Plugins multimedia Wordpress | El Blog de Negu
  24. 50+ WordPress Plugins for Multimedia - Learn Jquery Wordpress | Learn Jquery Wordpress
Read previous post:
Got iChat? Get Chax!

If you have a Mac and use iChat (who doesn't?), you absolutely MUST get Chax! I haven't been this excited...