Zenphoto Shorttags For Wordpress Plugin [Update 4]

January 12th, 2009 by Joen , , , ,

Few know it: Zenphoto is the best web gallery CMS there is. It is minimalistic, fast and stable. It powers this bloggers photostream, and its pictures grace these posts. Zenphoto is so great because the process of cropping, scaling and managing image cache is elegant, excellent, awesome.

This plugin allows you to take that scaling- and cache-management with you to Wordpress.

That means, and read this carefully: you can insert what amounts to a symbolic link to an ultra-high-res Zenphoto image, specify width and the height as an attribute and have Zenphoto do the scale work for you. Even if you replace the source image, you can just purge the Zenphoto cache — all images linked using this plugin will have their scaled versions updated from the new source material. Chew on that one for a while: it’s paradigm changing. That’s what it is.

Not the plugin, mind you, Zenphoto is paradigm changing. This plugin is just an enabler, minimalistic middle-ware. Once installed, in your Wordpress posts and pages, you can write:

[zenphoto src="filename.jpg" width="600" album="album/subalbum"]

… and you’ll get a gorgous image of cows, provided you named the cow image “filename.jpg and placed it in an album called “subalbum which resides in the “album album:

pic156.jpg

If you configure your default values correctly (you can provide defaults for widths and album), all you have to write is [ zenphoto src="filename.jpg"]

Required parameters:

  • src
  • width

Optional parameters:

  • album
  • height
  • class
  • alt
  • link
  • crop (options: tl, tr, bl, br for topleft, topright, bottomleft and bottomright)

Future plans include adding parameters for watermarks, a feature thats already in the Zenphoto core.It is with regret that I’ve had to add an options page. The only thing it does, is take your information as to where you installed Zenphoto (it has to know, it’s the only integration it has). Other than that, I’ve made things real simple; if you forget parameters or forget to configure the path, the plugin will show error messages reminding you what to do.

One last thing: this plugin is different from other Zenphoto / Wordpress plugins, in that it adds a link to the image object, not the cached image. That means you get the benefit of being able to change the size as many times as you want, as you author your posts, by simply changing the parameters. Don’t worry about the cache, by the way, Zenphoto magic makes sure that if the linked image object has already been rendered in your cache, the cache is shown.

Download Zenphoto Shorttags

[Update]: Version 1.1, added a parameter, link, which when “true auto links to the Zenphoto image in your gallery.

[Update 2]: Version 1.2, New options. You can now specify defaults for width, album and class. Effectively that means you can insert a zenphoto image with only [ zenphoto src="filename.jpg"] provided you have entered proper default values.

[Update 3]: Version 1.3, Added a crop parameter. Right now it’s a rather limited crop. crop="tl" crops the image so that it is unscaled, and top left aligned (hence tl). Also possible, tr, bl, br, for topright, bottomleft and bottom right. Works in conjuction with width and height parameters.

[Update 4]: Now on Wordpress.org.


Websites linking to this post:

  1. Wordpress UK » Noscope | Journal | Zenphoto Shorttags For Wordpress Plugin

Comments (19)

  1. Aaron Storm says:

    Great job Joel.

    The only thing that bothers me is that now we have a bit of cruft with the images pointing to i.php. Maybe it is possible to have a nice permalink setup for it.

    Quote

  2. Aaron Storm says:

    oops... Sorry about that Joen.

    I wasn't worry about SEO. It was just about being able to see how it's hooked up behind the scene (in the html). On another front, since within WP, the info is contained within the short tag, so there won't be a lot of heavy lifting if in the future one want to switch from zenphoto to something else (or, even worse, from WP).

    Is there any concerns for DOS attack by flooding i.php to create and cache images with various sizes? Use up CPU and cache?

    Your contribution to WP are really great examples for other to share and learn from your code. It makes me want to be able to share the same high-quality plug-ins and themes as yours.

    Quote

    • Joen says:

      Is there any concerns for DOS attack by flooding i.php to create and cache images with various sizes? Use up CPU and cache?

      There has been, but it is my honest impression that the Zenphoto guys have done plenty to prevent this from happening.

      Your contribution to WP are really great examples for other to share and learn from your code. It makes me want to be able to share the same high-quality plug-ins and themes as yours.

      Thanks, very much appreciated. Honestly though, I'm really just building the stuff I need myself, both in cases of themes and plugins.

      Quote

  3. baron says:

    Works great, thank you

    Quote

  4. Carrie (subscribed) says:

    Hi There, I'm getting the following error:
    Warning: getimagesize(/zenphoto/zp-core/i.php?a=2009-05-17&i=IMG_7440.JPG) [function.getimagesize]: failed to open stream: No such file or directory in [edit]/wp-content/plugins/zenphoto-shorttags/zenphoto-shorttags.php on line 65

    This is the code in my post:
    [zenphoto src="IMG_7440.JPG" album="2009-05-17"]

    Running zenphoto version 1.2.4 & wordpress 2.7.1
    Any idea what would be causing it? or how to fix it?
    Thank you!

    Quote

    • Joen says:

      Yes.

      There are only a few reasons why this error will appear, assuming your Zenphoto installatoin has been tested and works.

      One is if you're trying to scale a small image up, i.e. the source image is smaller than the size you're trying to insert.

      The other option is that you have somehow typed in a wrong filename, a wrong albumname or a combination of the two.

      Have you defined any defaults?

      Do you have a URL I can look at?

      Quote

  5. Carrie (subscribed) says:

    Here is the post: http://www.the-fosters.org/?p=128

    My settings are:
    URL to your Zenphoto installation: /zenphoto/
    Default image width: 500
    Default album: albums
    Default CSS class:
    Link images: Not Linked

    The image shows, but it gives the error at the top.

    Thanks for your help!

    Quote

    • Joen says:

      So the image does show up? Very odd.

      For one thing, try removing the value "albums" from the default album value.

      The thing is, the default album value does not refer to the zenphoto "albums" folder. It refers to one of the subfolders of that folder. Let me know if that helps.

      Quote

    • Joen says:

      I fixed it.

      I found out why the error happened, and I have uploaded a fix to the Wordpres plugins repository. Any time soon you should see the yellow "update" bar in your plugins page.

      Quote

  6. Carrie (subscribed) says:

    Great, thank you! I'll update it and let you know how it works :)

    Quote

  7. Carrie (subscribed) says:

    Just applied the update, no more error. Thank you for your help!

    Quote

  8. Bjork (subscribed) says:

    Hi, Thank you for great plugin !!
    One thing though that would be a good to have in your plugin.
    That you can choose weather to link to your photo or your album/subalbum that contains your photo because I'm using highslide in my zenophoto albums so the link does not work.
    Anyways just a hint for further updates, keep up the good work :D
    Regards
    Bjork

    Quote

    • Joen says:

      Interesting idea, and not a bad one.

      How would you suggest I implement this?

      Oh and one thing you could do, would be to simply manually create the link (not so elegant, I know, but it works today):

      <a href="#" rel="nofollow">[zp src="lolcat.jpg"]</a>

      I think that should work. Let me know if it doesn't.

      Quote

  9. Bjork (subscribed) says:

    Yes I just used regular link in stead.
    But having this options would be so nice and easy.
    Just going to management and choose link to album instead of link to photo.
    And then it would link to the album that the displayed photo belongs to.

    Quote

    • Joen says:

      Bjork: Just going to management and choose link to album instead of link to photo.
      And then it would link to the album that the displayed photo belongs to.

      I think I can build that quite easily, but you realize that if I built it this way, all your photos would link to their albums with no option otherwise? Meaning: either all your photos link to themselves, or all photos link to their album?

      Quote

  10. Bjork (subscribed) says:

    That would be great !!

    Yes, I realize that and my opinion that is just fine, because my theme in zenphoto does show all photos in the album so vistors know where he is and can easily click on that picture in there: example: http://bjorkolvers.com/photos/index.php?album=2009%2F20090206BubbiEndurfundir

    Thanks a lot !

    Bjork

    Quote

Comment

(required)

(required)

Textile

Textile is a method that uses simple symbols to quickly write rich text markup. These are the most common:

  • _emphasis_
  • *strong*
  • -deleted text-
  • !imageurl.gif!