Zenphoto Shorttags For WordPress Plugin [Update: Semi-retired]

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:
[raw]

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

[/raw]
… 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:

[zenphoto src="pic156.jpg" width="600" album="photography/sweden"]

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

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

Download Zenphoto Shorttags

Parameters

Required parameters:

  • src
  • width

Optional parameters:

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

Available Short-tags

  • [raw][zenphoto src="filename.jpg"][/raw]
  • [raw]
    filename.jpg
    [/raw]

Crop

Crop is currently partially implemented. If you enter it as a parameter, 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. The crop currently keeps the image unscaled.

Media Button

Since version 1.8, the plugin adds a media button for inserting images directly from your zenphoto gallery. It makes inserting the shorttag symlinks really easily. You can also upload from this interface.

Shorttags_02.png

Shorttags_03.png

Shorttags_04.png

[Update]: Zenphoto Shorttags is no longer actively developed. Instead, I’m working on Image Symlinks, which can take the place of this plugin. Please contact me if you wish to adopt this plugin, though.

Responses to “Zenphoto Shorttags For WordPress Plugin [Update: Semi-retired]”

  1. [...] Noscope | Journal | Zenphoto Shorttags For WordPress Plugin This entry was posted on Monday, January 12th, 2009 and is filed under WordPress News. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site. « x-keep: Daftar CMS Berdasarkan Kategori thomas.apestaart.org » WordPress frustrations » [...]

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

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

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

  4. baron says:

    Works great, thank you

  5. Carrie 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!

    • 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?

  6. Carrie 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!

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

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

  7. Carrie says:

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

  8. Carrie says:

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

  9. Bjork 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

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

  10. Bjork 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.

    • 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?

  11. Bjork 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

  12. Joen says:

    An update to this plugin adds a media button. Quite a cool feature, if I may say so myself.

  13. baron says:

    Works great, thank you

  14. Jeremy says:

    Hey,

    I’m trying to basically do exactly what this plugin does, but there’s one issue–my zenphoto login isn’t a subdirectory of my wordpress blog, in fact, it’s a different domain entirely…I tried just putting a full http:// qualified URL in the options for the shorttags, but I received an error, which I resolved by changing the code as follows:

    $zp_webpath = get_option(‘zp_url’);

    Which seemed to make it somewhat more happy, but now it’s complaining that the function zp_loggedin isn’t defined.

    Thoughts?  I don’t mind hacking code to get it to work, but I don’t want to do anything stupid.  :)

    Thanks!

    • Joen says:

      Well that’s odd… I have a full http:// url in my options page and it’s working fine.

      Can you post the error message you’re getting?

    • Scott Little says:

      I’m also having an issue with this. The error that I am getting is the following, when I try to use the media browser:

      Warning: require_once(../../..http://lnphotos.littlenet.eu/zp-core/template-functions.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/littlenet/blog/wp-content/plugins/zenphoto-shorttags/zenphoto-shorttags.php on line 39

      Note that manually inputting the link works okay, but it would be nice to be able to use the browser as well.

      • Joen says:

         

        Scott Little: I’m also having an issue with this. The error that I am getting is the following, when I try to use the media browser: Note that manually inputting the link works okay, but it would be nice to be able to use the browser as well.

        Have you updated the path to Zenphoto in the options page?

         

  15. I get the same warning as Scott Little trying to use the media browser. I can use the shorttag, but as Scott said: it would be nice to be able to use the browser as well. I have put the correct path in the options page, yes.

    Any ideas of how to correct this?

  16. Would it be possible to add support for title=”xxx” tags in Zenphoto Shorttags? I like it when hover triggers the image title…

    • Joen says:

      Tell you what: Come early next year, I’ll give the plugin a thorough overhaul and look into any of the error messages you have, and I’ll add both caption and title attributes!

  17. Brian says:

    Hi there. This is really a good thing.
    But I’m wondering if there is a shortcode that I am missing to show the thumbs from an album. In order, random, just a few, all of them, etc.
    I suppose it might look like:
    [zenphoto album="album/subalbum" number=20 display="latest"]

    (or display random, all etc)

    Or is shorttags only for single images?

    thanks!

  18. Carrie says:

    Hi Joen,

    I noticed you had considered making the wpautop feature optional. I would like to request this! Sometimes, I like to put two smaller images next to each other instead of always underneath.

    Thanks again for the great plugin!
    Carrie

    • Joen says:

      I noticed you had considered making the wpautop feature optional. I would like to request this! Sometimes, I like to put two smaller images next to each other instead of always underneath.

      Fixed this now. Look for 1.9.5 in the repository soon.

  19. Sundeep Goel says:

    Had some issues issues using this in Wp3.2, had to make following changes, not sure why, can you comment?

    $zp_webpath = ‘../../..’ .str_replace(get_bloginfo(‘home’), ”, get_option(‘zp_url’)); //original
    $zp_webpath = ‘../../../..’ .str_replace(get_bloginfo(‘home’), ”, get_option(‘zp_url’)); //modified

    var filename = ‘ src=”‘ + jQuery(this).children(‘span.filename’).html() +’”‘; //original
    var filename = ‘ src=’ + jQuery(this).children(‘span.filename’).html(); //modified

    var album = ‘ album=”‘ + jQuery(this).children(‘span.album’).html() +’”‘; //original
    var album = ‘ album=’ + jQuery(this).children(‘span.album’).html(); //modified

Leave a Reply