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.

Installation:
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]

122 Responses

  1. Richard Brown's Gravatar

    Posted by Richard Brown

    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?

    Rich

  2. Richard Brown's Gravatar

    Posted by Richard Brown

    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.

    Rich

  3. nate's Gravatar

    Posted by nate

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

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

  4. nate's Gravatar

    Posted by nate

    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's Gravatar

    Posted by nate

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

  6. nate's Gravatar

    Posted by nate

    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. Vamsi Gangavalli's Gravatar

    Posted by Vamsi Gangavalli

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

  8. Brian's Gravatar

    Posted by Brian

    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's Gravatar

    Posted by Brian

    Sorry, I forgot to put my email address.

  10. nate's Gravatar

    Posted by nate

    Brian,

    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's Gravatar

    Posted by Rick

    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's Gravatar

    Posted by nate

    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's Gravatar

    Posted by Rick

    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's Gravatar

    Posted by nate

    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's Gravatar

    Posted by Rick

    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's Gravatar

    Posted by nate

    *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's Gravatar

    Posted by Brian

    Hey thanks Nate, I will try that!

  18. Joel's Gravatar

    Posted by Joel

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

    Thx

  19. nate's Gravatar

    Posted by nate

    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's Gravatar

    Posted by Joel

    this is the url

    http://www.whoisddr.com/blog/gallery/?path=windstruck%20gallery

    Did I have to modify in the css the :

    a

    a:hover

    a:active ?

    thx

  21. nate's Gravatar

    Posted by nate

    Joel,

    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's Gravatar

    Posted by Joel

    Thanks very much

    work well !!!

  23. nate's Gravatar

    Posted by nate

    Awesome!

  24. Jan's Gravatar

    Posted by Jan

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

    Photos
    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:
    uploads

  25. nate's Gravatar

    Posted by nate

    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.

  26. Ant's Gravatar

    Posted by Ant

    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?

  27. nate's Gravatar

    Posted by nate

    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.

  28. Ant's Gravatar

    Posted by Ant

    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?

  29. nate's Gravatar

    Posted by nate

    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.

  30. Richard Brown's Gravatar

    Posted by Richard Brown

    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!

    Rich

    P.S. Hope you had an awesome Sunday!

  31. Tony A.'s Gravatar

    Posted by Tony A.

    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,
    Tony…

  32. nate's Gravatar

    Posted by nate

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

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

  33. Richard Brown's Gravatar

    Posted by Richard Brown

    Hi Nate

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

    Answers on a postcard to…..

    Rich

  34. Richard Brown's Gravatar

    Posted by Richard Brown

    Hi Nate

    A couple of things. If you take a look at:
    http://www.cregy.co.uk/snow-in-lostwithiel/
    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.

    Thanks

    Rich

  35. nate's Gravatar

    Posted by nate

    Rich,

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

  36. Billytheradponi's Gravatar

    Posted by Billytheradponi

    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,
    Billytheradponi

  37. nate's Gravatar

    Posted by nate

    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.

  38. Billytheradponi's Gravatar

    Posted by Billytheradponi

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

  39. nate's Gravatar

    Posted by nate

    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.

  40. Billytheradponi's Gravatar

    Posted by Billytheradponi

    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

  41. Billytheradponi's Gravatar

    Posted by Billytheradponi

    Oh and half the template doesn’t show either?

  42. nate's Gravatar

    Posted by nate

    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?

  43. Billytheradponi's Gravatar

    Posted by Billytheradponi

    5 i think, they might be updating it though…

  44. Billytheradponi's Gravatar

    Posted by Billytheradponi

    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…

  45. crb3's Gravatar

    Posted by crb3

    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.

  46. nate's Gravatar

    Posted by nate

    crb3,

    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.

  47. crb3's Gravatar

    Posted by crb3

    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)) {
    rsort($files);
    $wcount=4; # make sure it’s initialized
    –x– snip
    if (file_exists(“$dir/$str_path/$vf”)) {
    … look for thumbnail…
    }else{
    …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.

  48. crb3's Gravatar

    Posted by crb3

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

  49. crb3's Gravatar

    Posted by crb3

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

  50. nate's Gravatar

    Posted by nate

    crb3,

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

  51. Anonymous's Gravatar

    Posted by Anonymous

    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

  52. nate's Gravatar

    Posted by nate

    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.

  53. Mauricio's Gravatar

    Posted by Mauricio

    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
    http://www.mvalenzuela.com

  54. nate's Gravatar

    Posted by nate

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

  55. Chris Flattley's Gravatar

    Posted by Chris Flattley

    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?

  56. nate's Gravatar

    Posted by nate

    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.

  57. Chris Flattley's Gravatar

    Posted by Chris Flattley

    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.

  58. nate's Gravatar

    Posted by nate

    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.

  59. nuelle's Gravatar

    Posted by nuelle

    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?

  60. nate's Gravatar

    Posted by nate

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

  61. nate's Gravatar

    Posted by nate

    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.

  62. simple man's Gravatar

    Posted by simple man

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

  63. Debbie's Gravatar

    Posted by Debbie

    Nate:
    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?

    Thanks.

  64. Debbie's Gravatar

    Posted by Debbie

    Nate:

    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.

    Thanks.

  65. nate's Gravatar

    Posted by nate

    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.

  66. Debbie's Gravatar

    Posted by Debbie

    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:
    /public_html/blog/wp-content/uploads
    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.

  67. mr nice ash's Gravatar

    Posted by mr nice ash

    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.

  68. Debbie's Gravatar

    Posted by Debbie

    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?

  69. mr nice ash's Gravatar

    Posted by mr nice ash

    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.

  70. nate's Gravatar

    Posted by nate

    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

  71. mr nice ash's Gravatar

    Posted by mr nice ash

    thanks nate.

    i’m using it now.

  72. nuelle's Gravatar

    Posted by nuelle

    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.

  73. nate's Gravatar

    Posted by nate

    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.

  74. mr nice ash's Gravatar

    Posted by mr nice ash

    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?

  75. Debbie's Gravatar

    Posted by Debbie

    Guys:
    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

  76. nate's Gravatar

    Posted by nate

    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?

  77. nuelle's Gravatar

    Posted by nuelle

    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

  78. nate's Gravatar

    Posted by nate

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

  79. mr nice ash's Gravatar

    Posted by mr nice ash

    where can i get the latest update?

  80. Debbie's Gravatar

    Posted by Debbie

    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.

  81. nuelle's Gravatar

    Posted by nuelle

    @ 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

    [Checkbox]

  82. nate's Gravatar

    Posted by nate

    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.

  83. mr nice ash's Gravatar

    Posted by mr nice ash

    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.

  84. Joel's Gravatar

    Posted by Joel

    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.

  85. nate's Gravatar

    Posted by nate

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

  86. nuelle's Gravatar

    Posted by nuelle

    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.

  87. nate's Gravatar

    Posted by nate

    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.

    nuelle,
    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?

  88. nuelle's Gravatar

    Posted by nuelle

    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?

  89. Stan's Gravatar

    Posted by Stan

    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

  90. nate's Gravatar

    Posted by nate

    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.

  91. Jason's Gravatar

    Posted by Jason

    Nice plugin!

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

    Thanks very much!

  92. nate's Gravatar

    Posted by nate

    Awesome! I added you to the wiki Gallery.

    Thanks Jason.

  93. mr nice ash's Gravatar

    Posted by mr nice ash

    i added mine. hope you dont mind.

  94. nate's Gravatar

    Posted by nate

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

  95. Joe Mosca's Gravatar

    Posted by Joe Mosca

    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

    http://site.xoxgift.com/mosca/gallery/

    please email modified code or detailed instructions.

    Thank you,

    Joe Mosca
    http://XOXGift.com

  96. Debbie's Gravatar

    Posted by Debbie

    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:

    uploads

    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?

  97. mr nice ash's Gravatar

    Posted by mr nice ash

    hi debbie,

    please verify if theses lines:

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

    were not commented. if so, uncomment them.

    hope this helps.

  98. claus hansen's Gravatar

    Posted by claus hansen

    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.

  99. gerg's Gravatar

    Posted by gerg

    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:
    uploads

  100. Karen's Gravatar

    Posted by Karen

    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:

    alt=\"$v\"

    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…

  101. Pedro Carrillo's Gravatar

    Posted by Pedro Carrillo

    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.

  102. Pedro Carrillo's Gravatar

    Posted by Pedro Carrillo

    It’s working now, I uncommente the lines:

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

    Thanks…

  103. Dann S. Washko's Gravatar

    Posted by Dann S. Washko

    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.

  104. nuelle's Gravatar

    Posted by nuelle

    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:

    http://duhgallery.wikispaces.com/Download

  105. Dann S. Washko's Gravatar

    Posted by Dann S. Washko

    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.

  106. nate's Gravatar

    Posted by nate

    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.

  107. Derek Scales's Gravatar

    Posted by Derek Scales

    Blog work…

    Found a really nice plug-in for my blog the other day. Basically, for a while I have been wanting to add a gallery page to my blog and so I’ve gone through a number of possibilities with none of them working quite as I wanted. The main issue is t…

  108. Ham Radio Blog's Gravatar

    Posted by Ham Radio Blog

    Facelift: DL6KAC.de (now ham.blog.de) relaunched…

    I finally had the time and leisure to re-launch the non-blog part of my homepage. As you might remember I have reports & pictures about contest trips and a DXpedition to Hjelm Island online.
    The old design did annoy me since a long time. One of t…

  109. WORDPRESS GOD: 300+ Tools for Running Your WordPress Blog « Alex DiggMore's Gravatar

    [...] Duh Gallery – Creates a photo gallery from your uploads folder in WordPress. [...]

  110. Мега подборочка плагинов для wordpress | Записная книжка's Gravatar

    [...] Duh Gallery – создание фотогалереи из всех изображений, загруженных в блог. [...]

  111. Running Your WordPress Blog With 300+ Tools | oOrch Blog's Gravatar

    [...] Duh Gallery – Creates a photo gallery from your uploads folder in WordPress. [...]

  112. Галерея в WordPress это реально! Подборка Плагинов – Околоблог рунета's Gravatar

    [...] Duh Gallery – создаёт фотогалерею из изображений загруженных на WordPress. [...]

  113. Я Дизайнер! » Blog Archive » Плагины для WordPress's Gravatar

    [...] Duh Gallery – создание фотогалереи из всех изображений, загруженных в блог. [...]

  114. Criar site Grátis com o WordPress | Criar Sites's Gravatar

    [...] permitindo que você crie desde simples sites até complexos sistemas de classificados, fóruns, galeria de fotos, lojas virtuais e [...]

  115. Wordpress Photo Gallery Themes | Nate Ritter's Gravatar

    [...] the creation of my WordPress photo plugin called Duh Gallery, hundreds of thousands of people have hit this blog looking for the perfect photo gallery. [...]

  116. WordPress Tools Collection | indimovi's Gravatar

    [...] Duh Gallery – Creates a photo gallery from your uploads folder in WordPress. [...]

  117. 50+plugin wprdpress media | [K]4[V]N.NET-All Keys For You!'s Gravatar

    [...] Duh Gallery – Simply creates a photo gallery from your uploads folder in WordPress. [...]

  118. wordpress photo gallery plugin | MaNoJpArEtA.iNfO's Gravatar
  119. Los mejores plugins para Wordpress | TiDul's Gravatar

    [...] Duh Gallery – Crea una galería a partir de los imágenes de tu directorio de uploads. [...]

  120. 50 Excellent Image Galleries You Can Use Today « Shafaat Awan's Gravatar
  121. WORDPRESS GOD: 300+ Tools for Running Your WordPress Blog « © 1999 – 2009 Lololov World ™'s Gravatar

    [...] comment system. Batch Image Uploader Upload and resize multiple images to your blog at once. Duh Gallery Creates a photo gallery from your uploads folder in WordPress. ImageManager Includes interface for [...]

  122. Compartiendo Enlaces: 36 Wordpress Plugins — Pablo del Rio's Gravatar

    [...] Duh Gallery – Crea una galería a partir de los imágenes de tu directorio de uploads. [...]