![]() |
|
How to show random picture? - Printable Version +- ZenphotoCMS Forum (https://forum.zenphoto.org) +-- Forum: Support (https://forum.zenphoto.org/forum-1.html) +--- Forum: General support (https://forum.zenphoto.org/forum-4.html) +--- Thread: How to show random picture? (/thread-6.html) |
How to show random picture? - Joen - 19-09-2005 Anyone up to the task of writing code that displays a random image from all the galleries? How to show random picture? - reidab - 19-09-2005 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. ` How to show random picture? - Joen - 19-09-2005 Works perfectly! If I manage to add the permalink myself, I'll post it here How to show random picture? - Joen - 19-09-2005 Hmm. I was close, but no success. Let me know if you manage to add a link. How to show random picture? - trisweb - 19-09-2005 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. How to show random picture? - reidab - 19-09-2005 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? How to show random picture? - billyum - 20-09-2005 Is there any way I can call these random pictures on my Wordpress pages? For example, at my site, I use a flickr badge to display random photos. I'm trying to switch away from flickr and would like to keep this feature... How to show random picture? - reidab - 20-09-2005 Since you were using the flickr badge style before, I fashoned this using the same technique that they use. First save this into your zen directory as random.php ` How to show random picture? - trisweb - 20-09-2005 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 ;-) How to show random picture? - reidab - 20-09-2005 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. How to show random picture? - Joen - 20-09-2005 reidab, Did you manage to get the link for the code you posted first? How to show random picture? - Joen - 20-09-2005 I managed to bend it to my will. Thanks for your code, reidab. This is what I ended up with: `` To then show the random image, I use this code: ` How to show random picture? - somebear - 21-09-2005 Just a quick question. In every instance of the How to show random picture? - trisweb - 21-09-2005 True, but it really won't hurt that much. It's a hack to begin with, so why are you surprised? Tweak it as you like. How to show random picture? - beej - 23-09-2005 Joen, I like how you've incorporated it directly into your theme. Just wondering where exactly you put the file and what code did you use to call up the random photo. Thanks. How to show random picture? - Joen - 23-09-2005 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 How to show random picture? - simon - 13-11-2005 hi guys, i have been trying to implement the random image funtion onto the front page of my ZP theme, but i cant seem to make it work. Im not clear on how to do it. Any pointers? Thanks How to show random picture? - lorello - 28-11-2005 Thanks reidab, See you, How to show random picture? - 3stripe - 22-02-2006 Can anyone advise on how to tweak this code to give a Flickr style badge for use in the Wordpress sidebar (2 images across, 4 down for example). My php is shocking :-( How to show random picture? - 3stripe - 03-04-2006 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 |