Lazy-K Gallery

Copyright 2006 Korey Atterberry


The Lazy-K Gallery is a WordPress plugin that tries to make creating a photo gallery on a website as easy as possible.  It is based on “Lazy Gallery” by Nicholas Bruun Jespersen.

Lazy-K Gallery allows a photo gallery to be embedded onto a WordPress Page.  It doesn’t require complex configuration and relies on the user uploading image files manually into a folder structure (via FTP, etc.) instead of using a web interface.

Lazy-K Gallery offers the following features:

  • easy image uploading and management via FTP
  • integration into WordPress as a true plugin
  • thumbnail and slide caching
  • ability to comment on each image or folder individually
  • optionally use Lightbox or Thickbox for displaying images
  • include a gallery on a WordPress page or blog post
  • display just a portion of your gallery using “subgalleries”

For an example of Lazy-K Gallery in action, see my Example Gallery or any of these fine websites. You might also take a look at my FAQ page for more information an using Lazy-K Gallery. Need help? Take a look in the forums.


The latest version of Lazy-K Gallery is 1.4. Download it with the link below:

If you’re upgrading from a version prior to 1.3, I’d recommend you visit the Cache Manager from the options page and rebuild your cached images. If you have any problems, drop me a line and I’ll help you out. Old versions and a list of changes can be found on the Version History page.

Basic Installation:

  1. Create a folder inside your WordPress installation directory for your photos and upload them into whatever directory structure you want. You may need to change the permissions on that folder to 755.
  2. Copy the lazy-k-gallery.php file and the lazy-k-gallery folder into your WordPress plugins directory (wp-content/plugins).
  3. Activate the Lazy-K Gallery plugin from the Admin Panel > Plugins screen.
  4. In Admin Panel > Options > Lazy-K Gallery, enter the root directory for your photos folder and modify the other settings if you want to.
  5. Hit the “Create Page” button. It will create a page for the gallery. You can edit it if you’d like to change the title, body, slug, etc.

Advanced Setup:

Once you’ve performed the basic steps above you should be ready to go. All of the steps below are optional.

Page creation

If the “Create Page” button doesn’t work, you can create the gallery page manually. Create a new WordPress Page and enter the text <!–lazy-k-gallery–> where you want the photo gallery to appear.

Pre-creating slides and thumbnails

If you want to create your thumbnails and slides ahead right away, you can use the cache manager. If you don’t create these, the first time someone visits a folder within your gallery they will experience a delay.

Visit the Cache Manager from the options page. Check the “create” checkboxes to create all your thumbnails and slides. If you want to recreate existing thumbnails and slides, use the “delete” and “create” checkboxes.

Enable per-picture commenting

If you want to enable commenting on each image/folder individually, you will need to edit your comments template within your theme. Edit the following file within your WordPress installation:


If you are using a theme other than “default”, edit the file within that theme’s folder instead. You could also edit this file from your admin panel by choosing Presentation > Theme Editor > Comments.

You should have a couple of lines that look something like:

<!-- You can start editing here. -->
<?php if ($comments) : ?>

Put the following line between them:

<?php if (function_exists('lzk_filter_comments')) {$comments = lzk_filter_comments($comments);} ?>

If you have any problems with making that change, just send me a note and I’ll help edit your comments.php file.

Creating Subgalleries

A “subgallery” is just a subset of your full gallery, starting at a given directory. Using subgalleries, you can essentially have multiple galleries on one site. Also, you might use this feature to share just a portion of your gallery in a post or page. Let’s say you’ve uploaded a new folder to your gallery – you could include just that folder in a subgallery in a blog post.

To display a subgallery, create a post or page and include the following tag:


This tag will display a subgallery consisting of all your photos from the “Animals” folder in the root of your gallery.

Known Issues

  • In order to make per-picture commenting work, you have to edit the comment template in your theme. Hopefully WordPress will add a hook for this filter in a future version.

These issues will be addressed in future releases.  Please leave any other suggestions using the comments form below.  Keep in mind the goal is to keep this plugin simple.  There are other gallery plugins available that are much more powerful than this one. I do have a list of planned improvements that I’m considering.


Thanks to…

  • Nicholas Bruun Jespersen for creating the original Lazy Gallery.
  • Marius Kroon and Will for helping work out the initial bugs
  • Mark Jaquith and “io_error” for help in coding the per-picture commenting
  • Paul Kimbrel for help setting up the Ajax stuff
  • Garrett Bartley for solving a problem with single quotes in file/folder names
  • Mike for help with dots in file names and replace underscores feature
  • Bent Graphics for testing help
  • Josip Medjumurac for help with integrating with Thickbox
  • Adeola Awoyemi, Tim Rowe and Sascha for finding and helping to correct some issues


This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

177 Responses to “Lazy-K Gallery”

  1. max says:

    sorry but I can’t show the code that cause your gallery to appear in a page… but you understand..

    sorry again..

  2. Shakeb says:

    Hi Korey,

    Thanks for your great gallery.
    I was just wondering if it is possible to have square thumbnails or equal sized thumbnails for all images.
    This is my gallery at the moment

    If all thumbnails were of the same size the page would look much more neat and tidy.

    Thanks and Regards

  3. Hansje says:

    I have exactly the same problem as you Max! 🙁

    Not Found
    The requested URL //?page_id=4&lzkfile=Album+-+Fotos+van+Hansje+zelf%2FDSC03399.jpg was not found on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

    when i go back, my comment is stored :s

  4. Arturo says:

    very very very beatiful and usefull gallery!
    but there are an error, the chmod of folder for the picture are 777 not 755 🙁

  5. Ed says:


    Thanks for the plugin! One question, is there any reason that my pictures wont load if I don’t choose to have the filename displayed? If I check it off I just get little squares, as soon as I set to disply the filename, I can see the pictures.

  6. Ed says:

    hey! nevermind. realized it was a k2 problem, found a fix on your site somewhere. thanks for the great plugin.


  7. David says:

    Dear Korey

    As you can see I also created a WordPress blog. I installed your plugin and it is worling fine! I searched a lot after something like this 🙂
    You can find the page over here:
    Three small “comment”, is there a possibility to get rid of:
    – the date and everything that is behind there. Especially on the main picturepage.
    – the possibility to give comments on the main picture page en the folder pages. I only want them to give comments on the pictures themself!
    – The thing with the pictures. I just want them next to each other something like you did on the example page!

    I don’t know if these things are possible, but I truly hope so!


  8. David says:

    – The thing with the pictures. I just want them next to each other something like you did on the example page!

    I was ably to leave that one out, but now they are all on the same line. What do I have to add, to put them on a new rule every 5 thumbs or something…


  9. Korey says:


    First, the issue with your pictures not laying out right… for some reason your website isn’t including the header information for your plugins, including Lazy-K Gallery’s stylesheet. Take a look in your theme’s header.php and see if there is a mention of wp_head(). If it’s not there, take a look at the default theme to see where it goes. Let me know if that solves your problem.

    Commenting on photos only… I’ve had that request before, and there’s no easy solution at this time.

    I don’t understand what you’re asking about “the date and everything behind there.” If I’m guessing correctly, you don’t want to see the post date above the gallery. To change that, you’ll need to change your themes page.php file and remove the reference to the date. That will change ALL of your pages though, so perhaps you might like to create a new page template instead. See the WordPress Codex for how to do that.

  10. Mike says:


    Issue 1:
    My folders are all named year.month(.day)_Description_with_Underscores

    When I tried to open one of those folders, I got a view of a placeholder for a picture, but no picture. I beLIEve that the issue was the dot in the folder name. Can you confirm whether this is the case or not by trying a folder containing dots?

    I may be back with an “Issue 2” later, but I want to try something first.

  11. Mike says:

    Issue 2:

    How about a feature whereby I can tell it how to order the files?

    I really want everything in order by name, but the readdir function orders them by their order on the hard drive, which makes for some weird chronology when I’ve got a vacation gallery.

  12. Korey says:

    Mike- on issue 2, that’s a known oversight on my part. I’m planning to release a maintenance release before too long to address that issue and a couple of others. If you’re up to it, look at all the places where I do a readdir and add the natcasesort like I used in a few places.

  13. Mike says:

    I was able to get things in alphabetical order with the natcasesort function. I figured that, but it took some playing to make sure I did it right.

    Feature requests:
    One: Replace underscore with spaces in folder names and image names

    Two: “Pretty URLs.” The addresses shore would look purdier without the “?lzkfile=” in there. I’m going to see what I can do on that front, but from what I’ve looked at so far, it doesn’t appear to be easy. It’s gotta be possible, but since I don’t know how, I’ll do some digging.

    What I’m going to look for is some way to first check to see what page we are. What is the actual address of the page that has the commented lazy-k-gallery tag. Once I have that, we should be able to strip that off and everything before it to see if there is anything (directory, filename, whatever.) I guess before I do that, I’d have to check to see if the .htaccess file is being used to make things pretty or else it won’t work for people who have ?something=whatever.

    That may not make much sense. I don’t know how to explain it better. Maybe you’ve already look and have found it to be impossible. I don’t know. I’ll check it out and see what I can find though.

  14. Lee says:

    Great plugin! I am new to WP and it was easy to install. 2 Questions:

    1- My comments do not work, and there is no page.php file in my theme. Any ideas?
    2- How could I go about displaying a thumbnail for each of the galleries instead of only the text description?

  15. Mike says:

    Here’s what I have so far re: “pretty URLs”

    Dunno how well pasting PHP code works, but I’ll try:

    function lzk_redirect($rules)
    $page_name = get_option(lzk_page_name)
    $rules[‘($page_name)/(.*)$’] = ‘index.php?pagename=$1&lzkfile=$2’;
    return $rules;
    add_filter(‘rewrite_rules_array’, ‘lzk_redirect’);

    function lzk_query_vars($vars)
    $vars[] = “lzkfile”;
    return $vars;
    add_filter( ‘query_vars’, ‘lzk_query_vars’ );

    I got most of the info from so if you want to check that out and see what you can do, that’d be coooool. I haven’t tested this yet, and I expect I screwed something up so it won’t work, but I don’t know for sure yet.

    I’ll keep working on it in my rare occasional free time.

    I also added a new function to lazk-k-gallery.php along with the options in -config and a checkbox for it in -admin.

    function format_name($item)
    if (get_option(‘lzk_replace_underscore’)) {
    $item = ereg_replace(‘_’, ‘ ‘, $item);
    return $item;
    } else {
    return $item;
    Then when I’m printing an image name or directory name, I use format_name($dir) or format_name($img).

  16. Mike says:

    Other note:

    This only works if the lazk-k-gallery admin page creates the page with the
    !– lazy k gallery
    line so that it knows what the name of the page is, so there’d need to be another field for “Page name” or something that created a new page that had the content in it. That page would then theoretically be editable through regular editing means for adding text above or below the gallery itself if necessary.

    But then, if it gets changed on the admin page, then should it delete the old page? Or rename it? Or leave the old one and make a new one? And how to do that properly?

    Perhaps something like this on the options page:
    Name of the page: _____
    Text above the gallery (Optional): [text box]
    Text below the gallery (Optional): [text box]

    Then the admin page could create the page with those contents and add the rewrite rules for that page.

    Is that the proper way of doing that?

    Is that even something you want to do? Or should I quit now with the input?

    And were you ever able to test browsing into a directory with a “.” in it? Just to see if that’s the problem or not so that I can try to figure out *why* it’s a problem?

  17. Bryan says:

    Everything with the plug-in seems to be working well, but I can’t get the comment boxes to come up. I’ve inserted the code as the directions say, but it hasn’t changed anything.

    Here is a copy of my comments.php file:

    Here is a link to my gallery:

    Any input you have on what’s stopping me here would help me out a lot. Thank you for your time.

  18. mac says:


    Plug is really fantastic. However, for my purposes, I would really like to tweak it so I can have a gallery generated within a post. Any quick fix to add specificity to the gallery call tag?

    Also, anyway to skip the individual thumbnail page and go right to the original image from the gallery page?

    Thanks a ton.

  19. Korey says:


    You should be able to put your gallery in a post just fine by putting that tag in the post instead of a page. Are you asking for a subset of your gallery inside the post?


  20. mac says:

    Sorry, subset.

  21. Vince says:

    I tried to install the plugin, but when I click activate, my page goes blank as if the PHP isn’t parsing correctly, and I have to go through the ftp and remove the lazy-k-gallery.php file to fix it. Any idea why this is happening?

  22. This is good plugins…

    Plan to add uploader via web interface anytime soon?

  23. Chuck says:

    Awesome plugin! Thanks a lot for putting all the work into creating it. It’s much appreciated.

  24. Aboral says:

    I create the gallery but the thumbnails it doesn’t show up!

  25. Jaypee says:

    first of all, great plugin!

    secondly, i’ve installed it and got it working but my problem now is how to make it work with Lightbox or Thickbox. i’ve installed the ones you mentioned that work with this plugin but still can’t make the images to show up using Lightbox or Thickbox. hope someone can help me with this. thanks in advance! 🙂

  26. Korey says:


    All you should have to do is install and activate your chosen lightbox/thickbox script from the approved list and make the proper selections from the lazy-k gallery options page. Did you change the combo boxes in the lazy-k gallery options page? Drop me a note on the forum or from the contact page and we’ll see what’s going on.


  27. Korey says:

    Aboral- I see the problem occurs in Firefox but not IE. Take a look at, since it looks like a conflict with your theme. If that doesn’t help, drop me a note on the forum or contact page.

  28. jonathan says:


    THis looks like a great plugin. however, I’m having a bit of a problem. I installed it on my own website, and it’s working perfectly, but on another site i run,, after setup the gallery page ( produces a 404. Any help would be greatly appreciated.

  29. jonathan says:

    Hm, bizarrely, the page is now appearing (I haven’t done anything additional), but I can’t get into any of the subdirectories.

  30. Korey says:

    Jonathan- I don’t know exactly what is happening with your site, but I notice there are some script errors on the page (not in the gallery software). On line 263, you’ve got an error in your error message: “You’ve left out a required field!” That single quote in the string is messing things up, since that string is enclosed in single quotes.

    Now, I don’t know for sure whether that is affecting the gallery, but it’s possible. Drop me a note if you’d like to try some troubleshooting. I can send you a test version of the gallery software that could help point out where the failure is occuring.

  31. jonathan says:

    that error was coming from the “intouch” contact form plugin. i deactivated it and tried the gallery again still nothing doing. could you go ahead and send me that test version at this address? i’ll do my best to use it to figure things out, though i may not be as tech savvy as you hope 🙂

  32. Korey says:

    Jonathan’s problem was caused by using “gallery” for the name of his gallery page (actually, the stub used in the permalink) and also naming his folder to hold the photos “gallery” as well. When permalinks are enabled, both the folder and the page have the same URL: http://example/gallery.

    I will get this issue into the FAQ, since it has caused a few people issues, but the problem manifests in different ways.

  33. Lu says:

    This plugin gets better every day!!! Congrats!!!

  34. Dominik says:


    thanks for your plugin. It works nearly perfect 😉 As you can see from my homepage, I get a warning message (Warning: imagejpeg(): Unable to open..and so on) and I do not know where it comes from, because I have no problems on my other wordpress blog. Maybe you can help me 🙂

    Thanks a lot

  35. Dang Hai says:

    Hi Korey Atterberry,
    This is a great gallery for WP :D. There’s a small problem, much appreciated if you can fix….
    I’m encountering a problem with the display of sub gallery on the index page.
    I created a post, add the code

    The sub Gallery works, but all the comment counts on the index page will be zero (they actually have comments inside..), if I try to remove the subgallery into “Read More…” part of the post (mean the subgallery won’t be display on index page, user need to click Read More to see it), then the comment count will be correct again… weird ! What does the problem with lazy-k-gallery being integrating into post ?


  36. Mary-Ann says:

    Hi Korey,
    Is there some code for inserting a gallery or subgallery in my sidebar?

  37. James Irwin says:

    I have just installed the plugin, but i keep getting this error messange

    Warning: mkdir() [function.mkdir]: No such file or directory in /home/monkeysp/public_html/wp-content/plugins/lazy-k-gallery/lazy-k-gallery-image.php on line 129

    Warning: mkdir() [function.mkdir]: No such file or directory in /home/monkeysp/public_html/wp-content/plugins/lazy-k-gallery/lazy-k-gallery-image.php on line 129
    Processed: 061118 Nickys Northshore/dscf0035.jpg
    Creating thumbnail.
    Failed! – Could not create the directory: /home/monkeysp/public_html/Pictures/2006/061118 Nickys Northshore/lazy-k-thumbs
    Creating slides.
    Failed! – Could not create the directory: /home/monkeysp/public_html/Pictures/2006/061118 Nickys Northshore/lazy-k-slides

    I have tryed to sort it myself but have had no luck please can you advise!

  38. Alex Mielus says:

    Hi Korey,

    I’m using your excellent gallery on my portfolio’s page.

    Go to my site and see it so you know what I’m talking about. Go to this page for example:

    I would like to know if there is some way to put “banner Manhattan Deli.jpg” from the inside the page’s tag. Maybe using is_page() function … I don’t exactly know how or if it can be accomplished. (I think it is .lzk_formatFileName($path[‘basename’]). in the lazy-k-gallery.php file … but I don’t know how to pull it from there and get it to appear in the tag 🙁 )

    And a suggestion: maybe in a future version of the plugin you can implement some SEO friendly url for all the items in gallery. For the page in my example .. maybe you can make it appear like: 😉


  39. Alex Mielus says:

    PS: I was talking about the title tag …. but since it were between it didn’t appear .. sry 🙂

  40. Korey says:

    James Irwin- That sounds like a permissions issue. Have you tried doing a CHMOD on your gallery folder? The errors you’re seeing mean that the gallery software can’t create the “lazy-k-slides” and “lazy-k-thumbs” folders within your gallery. Try doing a CHMOD 755 or CHMOD 777 on the gallery folder using your shell or FTP client. If that doesn’t work, please start a thread on the support forums and we can go from there!

  41. Korey says:

    Dang Hai-

    I’m not aware of any specific problems with including a gallery on a post, since posts are mostly the same as pages. Could you please share with me your URL so I can take a look? If you don’t want to make your URL public you can send me a Private Message on the forums or use the Contact page. In order to help other users, could you please start a thread on the support forums? Thanks!

  42. Korey says:

    Alex Mielus-

    There’s no way to do what you’re suggesting with the current version of the plugin, but those are on my list of enhancements to do. Mike from had the exact same ideas that you had and has given me some suggestions. I can’t promise I’ll make these changes soon, because they’re pretty challenging and not often requested, but they are on my list. Thanks for the feedback!

  43. Korey says:


    I took a look at your site and don’t exactly see the problem you’re having. If you’re still having the issue, can you start a thread on the support forum? Thanks!

  44. Korey says:


    What exactly do want to show up in the side bar? The folders, thumbnails, slides? I do have a function that basically works for putting the gallery some place other than in a page, but there will be some issues, like per-picture commenting probably won’t work.

  45. Dang Hai says:

    I have post a bug report in Support Forums in Bug Report as per your request to help others solve same problem…
    I also send a PM to you my site URL and describe the problem, please check your PM Inbox…

    Thanks 🙂

  46. Mary-Ann says:

    Hi Korey,
    Sorry for not being clear, what I’d like is to show six or so thumbnails. They could be completely random, alphabetical order of filename, a subgallery or whatever’s easiest. I’m not to worried about commenting really.

  47. Anton says:

    Everything seems to work fine. But sadly the gallery doesn’t pop-up. I created the gallery page automatically, and it’s there, but when I click on the link, there’s an empty page!?

    What’s wrong?


  48. Ionia says:

    I just spent all day looking at and trying out different gallery plugins and yours is the best I’ve found 🙂

    Would it be possible to make something like the subgallery comment for putting a few sample images at the end of a post and then when one of those images is clicked, it takes you to the real gallery page instead of changing the gallery at the end of the post to a slideshow? I’ll probably want to put more than just a few images per gallery, but that would bloat the post pretty badly right now…


  49. Ionia says:

    Also, it looks like trying to post two subgalleries on the same page breaks XHTML 1.0 Transitional status…

    Error Line 54 column 9: ID “gallery” already defined.

    [div id=”gallery”][!–lazy-k gallery version 1.4–][div class=”breadcrumb”][p]No

    Changed angle brackets to square brackets, hopefully it will still show up…

  50. Now it suddenly automagically works. I did nothing but wait (and eat) and reload the page.

Comments on this page are no longer allowed. If you have a question or comment please see the support forums.