5Nov/09Off

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. You also get the [[zenphotopress]] shortcode that can be used for inserting galleries into posts, such as [[zenphotopress sort=random number=3 album=0]]. In this case, a random 3 images will be displayed from across all albums, as below:

[zenphotopress sort=random number=3 album=0]

However, it does not end there! Alessandro has also included a sidebar widget for displaying images from your Zenphoto galleries. This can show a configurable number of either random or latest images from across all albums or one specific album. Look to the right and you'll see that I have used it to display a single random image from across all albums. The only tweak I have made so far is to add some custom CSS via the LightWord theme settings to add enough margin to the thumbnail to get it centre-aligned. I may revisit this at a later date to get the thumbnail to fill the available space without scaling up and losing quality, but for now I am happy with the results.

Without a doubt the ZenphotoPress plugin is a vital part of this integration.

Theme Integration

This integration is good, but the problem is that the albums and images are still displaying in the default Zenphoto theme. As nice as this theme maybe, I want the gallery to fit seamlessly into my chosen WordPress theme, LightWord. This is where the work of Steffen Rusitschka and Einar Egilsson helps.

In his October 2006 post 'Integrating zenphoto into WordPress', Steffen Rusitschka described a simple method he used to match his Zenphoto theme to his WordPress theme. I'll leave the exact details to his original article, but basically his method involves creating a new theme in Zenphoto and adding all of the appropriate header, sidebar and footer references, leaving just the main content of each gallery template page in-between. Simple and effective.

Now Einar Egilsson took this a couple of steps further in his August 2007 post 'Integrating ZenPhoto into Wordpress'. Einar had two issues, first his Zenphoto JavaScript was not being loaded and second he wanted to be able to edit the Zenphoto theme from within WordPress along with his main WordPress theme. His solution was to abstract the Zenphoto theme back to the main WordPress theme. This is simply done by replacing the Zenphoto theme files with very simple scripts that have an include for matching files within the WordPress theme. They also each reference a common header script that imports the WordPress functions as in Steffen's post. This then allowed function calls to register the Zenphoto JavaScript and CSS with WordPress. This now allows you edit the Zenphoto theme files from within WordPress as with any other file in the theme.

Einar also threw in a little bonus - a small plugin that simply adds a link in the WordPress administration interface for accessing the Zenphoto administration.

So, as I stated at the top of this post, the work of three people has help me accomplish a pretty damn good integration, but...

Snag List

Unfortunately I still have a few gripes with my integration. One is serious problem, some of them may just be due to my Libran inclinations towards balance, harmony and perfection and some may be because I like a technical challenge, but either way, here's the list:

  • The serious problem is that although the gallery pages are displaying they are returning with a status code of 404! This is a serious issue as they will not be indexed by search engines. I get the feeling that some serious digging is required to get WordPress recognising these as desired. Some comments on Einar Egilsson's original post suggest that this is caused by the URL rewriting used by both WordPress and Zenphoto. The rewriting is staying as I want the friendly URLs, so a fix is needed.
  • Likely related to the first point, all of the gallery page titles are being displayed as "Page not found « Spark Hunt", as WordPress is looking for actual WordPress pages and obviously not finding any.
  • Once the gallery pages are returning status codes of 200, I would like to get at least the individual album pages included in a dynamic XML sitemap. I already have one being generated for the WordPress side of things, but how to integrate the gallery pages? Whether I end up with a single consolidated sitemap or separate ones for Zenphoto and WordPress, it all needs to be there somewhere.
  • Apart from what I might add to posts such as this one, the gallery is not being linked to. I think a "Gallery" button somewhere on the main navigation of the site would be a good idea, from both usability and SEO points of view.
  • I have installed the Sociable social bookmarking plugin for my WordPress posts and would really like to get it appearing on my gallery pages too.
  • I am planning on using the 'WordPress.org Stats' plugin to track the activity on this site, so can this be made to track gallery pages, even if they have to masquerade as standard WordPress pages? If not maybe I need to look at an external solution, such as Google Analytics?
  • I would like to use some fancy script for image display such as lightbox or highslide. These can be added separately to both WordPress and Zenphoto, but will everything be covered, such as Zenphoto images linked to from posts or pages?
Comments (3) Trackbacks (0)
  1. Hey! Did you get anywhere with that snag list?

    • I did make some progress before other commitments got in the way, you know how it is :)

      I resolved the 404 errors as detailed in this post and also got the page titles displaying nicely on the gallery pages. Regards XML sitemaps, I am currently using a zenPhoto plugin to generate these but Google is not indexing the individual photograph pages due to slow loading times. This is the next thing on my list to look at. I added a gallery link to the main navigation on the site simply by manually adding it to the template and I am now using the AddToAny service for social bookmarking.

      I have not yet looked into statistics for the gallery or any sort of lightbox effect.

  2. As for the lightbox effect, I added support for it in ZenphotoPress a couple of months ago. It will work only in Wordpress, of course, but it’s a start ;)

Trackbacks are disabled.