Here's a bit of code that I hacked together. It doesn't print a link to the image at the moment, but that's fairly easy to add. I have this running as random.php in my /zen directory and it grabs and displays a random image on refresh. I'll adapt it tomorrow to make it more useful as an insertable object.
`
Don't forget that image object it returns is mighty powerful - you can get [i]everything[/i] from it - link, thumbnail, full size, any size, next/prev image in the album, the album itself (and thus, all images in the album including the image), etc etc.
Randomness is a good idea though. When I implement sorting for the next version I'll add a random option, and also a "get random" method on both gallery and album (so, getRandomAlbum, and getRandomImage on both Album and Gallery depending on what scope you want to grab it from). Yay.
Is there a particular reason that getImageLinkURL is defined in template functions and not in Image?
It's not that there's anything wrong with it being in template functions, it's just harder to access there if you're working outside of the normal zenphoto contexts. Maybe define all of the functions that are currently called in template functions with no parameters to accept an optional image object and fall back to $_zp_current_image if no Image is passed?
True. I'd say you're going a bit too far out of the zenphoto architecture. Though I understand your desire to create something like this, this is what I would call a "hack".
Just know that I'm planning on making a "sidebar generator" widget that you can give some arguments like (total width, number of colums, number of rows, random or not, which album(s) to use) etc. It'll then create a DIV with columnsXrows images in it that's exactly as wide as you want.
To those of you who don't want to hack yet, remember this is a developer preview release, and I wouldn't reccomend switching away from flickr just yet.
reidab - regarding the placement of getAlbumLinkURL - yes, there is a reason. It does different things for different template contexts. If you're in an image, then the link points to the page of the album where the image resides; if not, then it just points to the album. Let's just say that if you're "working outside of the normal zenphoto contexts" then I'm not going to help you ;-)
Yes, this is definately and shamelessly a quick and dirty hack. I've been looking through the code since I wrote this and I've gotten a much better now for how things are actually structured.
Thanks for writing clean, OO code! It's such a wonderful break from the stuff that I have to slog through on a day to day basis.
Just a quick question. In every instance of the getRandomImage() function, the SQL statement fetches not only the filename and folder which are used to "make" the image, but also the title. This isn't used anywhere and I'm curious as to why it's fetched at all.
beej,
I would actually recommend against integrating things too closely at this time. ZP is still beta, and there are some ugly hacks in my integration, currently. I would recommend waiting until the core becomes a bit more mature.
That said, if you still want to integrate things, there's a brief explanation here:
http://www.noscope.com/journal/2005/09/zenphoto-08-released#comment-4569
Can anyone possibly help me with this if they have a moment?
I need to recode this to give 2 kinds of output:
Many thanks
James
PS. No-one ever answers my posts