Zenphoto Posts

12Nov/093

404 Errors When Integrating Zenphoto With WordPress

The Problem

In my previous post, 'A Basic WordPress And Zenphoto Integration', I noted that my Zenphoto integration had a problem with silent 404 errors. Although the pages of the gallery were being displayed nicely skinned with my WordPress theme and everything looked okay, behind the scenes they were being delivered to the browser with a HTTP status of 404, "not found". Obviously this is a very bad thing, as once I manage to get search engines indexing my site they would see the 404 and assume that the pages were not available, ignoring the fact that the content was actually there.

The Details

Some comments on the original post that I used to aid my integration suggested that this was being caused by the URL rewriting used by both WordPress and Zenphoto. Taking this lead, I did a few simple tests to narrow the location of the problem. First I disable the URL rewriting in Zenphoto. No change. Second, I disabled the URL rewriting in WordPress. Bingo; the gallery pages were now being served with a HTTP status of 200, but now my WordPress URLs were decidedly less than friendly.

Time for a bit of digging into how WordPress handles URL rewriting. Actually, not much digging was needed in this case. As the gallery is located in a sub-folder under the WordPress installation, I figured all that was needed was to make WordPress ignore this entire sub-folder when it comes to parsing rewritten URLs. This led me to 'WP_Rewrite' in the WordPress Codex. This class, defined in wp-includes/rewrite.php, handles all of the URL rewriting rules used by WordPress.

5Nov/093

A Basic WordPress And Zenphoto Integration

Having installed both WordPress and Zenphoto, it is now time to see how to integrate the two. A bit of searching through the WordPress Plugin Directory and quick session on Google led me to the work of three people that would help me to accomplish a pretty damn good integration.

ZenphotoPress

The first step was to install the ZenphotoPress plugin by Alessandro Morandi found in the WordPress Plugin Directory. This awesome plugin provides shortcode support and a dialog in the WordPress editor for inserting images from Zenphoto directly into posts and pages. For example, here are a few shots I took at a big cats workshop back in March 2009:

Ocelot Leopard Leopard Ocelot Snow Leopard Mountain Lion

The plugin gives a variety of options when inserting, such as whether to insert the image, it's textual name or custom link text. You can choose whether to link to the album, the individual picture page, a custom URL or even no link at all. Other options include such things as text wrapping and image size. In the example above, I have opted for thumbnail sized images linking to the main gallery page.

4Nov/090

Choosing A WordPress Photo Gallery

So, after reading Sara's post "Why YOU should blog" on www.developerdame.com I decided to finally get off my butt and start my own blog. I sorted some hosting and installed WordPress but I wanted more. I have an interest in photography and wanted a fully featured gallery that integrated with WordPress and fitted into whatever theme I happened to choose. A quick Google later and NextGEN gallery seemed to be the popular choice. First impressions were good; a good administration interface, thumbnail generation, a variety of choices for lightbox style display and a variety of shortcodes for displaying albums and pictures in both posts and pages.

However, NextGEN does not dynamically generate pages with friendly URLs for albums in the gallery. From what I could determine, each album would have to be manually attached to a page configured through WordPress and displayed via shortcodes. I guess I could have written a plugin that generated these pages for me, but I decided to investigate standalone gallery solutions and whether these could be successfully integrated with WordPress. Another session on Google led me to Zenphoto. Again, first impressions were good; a good administration interface, thumbnail generation, support for plugins and themes, but most importantly for me Zenphoto is simple and bloat-free. In the words of the developers:

Zenphoto is an answer to lots of calls for an online gallery solution that just makes sense. After years of bloated software that does everything and your dishes, zenphoto just shows your photos, simply. It’s got all the functionality and “features” you need, and nothing you don’t. Where the old guys put in a bunch of modules and junk, we put a lot of thought. We hope you agree with our philosopy: simpler is better. Don’t get us wrong though –zenphoto really does have everything you need for your online gallery, and you’ll even stare in awe at some of the innovative innovations we innovated upon.

Installation was a breeze and within five minutes I had a working vanilla gallery. So, how to integrate Zenphoto with WordPress...