Pages (4): 1 2 3 4   
Member
Member
Joen   19-09-2005, 10:32
#1

Anyone up to the task of writing code that displays a random image from all the galleries?

Member
Member
reidab   19-09-2005, 12:12
#2

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.

`

Member
Member
Joen   19-09-2005, 13:52
#3

Works perfectly! If I manage to add the permalink myself, I'll post it here

Member
Member
Joen   19-09-2005, 19:46
#4

Hmm. I was close, but no success. Let me know if you manage to add a link.

Developer
Developer
trisweb   19-09-2005, 20:25
#5

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.

Member
Member
reidab   19-09-2005, 20:46
#6

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?

Junior Member
Junior Member
billyum   20-09-2005, 00:04
#7

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

Member
Member
reidab   20-09-2005, 02:29
#8

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

`

Developer
Developer
trisweb   20-09-2005, 06:53
#9

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 ;-)

Member
Member
reidab   20-09-2005, 07:17
#10

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.

Member
Member
Joen   20-09-2005, 09:27
#11

reidab,

Did you manage to get the link for the code you posted first?

Member
Member
Joen   20-09-2005, 18:24
#12

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:

`

Junior Member
Junior Member
somebear   21-09-2005, 06:14
#13

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.

Developer
Developer
trisweb   21-09-2005, 06:59
#14

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.

Junior Member
Junior Member
beej   23-09-2005, 06:35
#15

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.

Member
Member
Joen   23-09-2005, 07:43
#16

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

Member
Member
simon   13-11-2005, 14:51
#17

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

Junior Member
Junior Member
lorello   28-11-2005, 17:44
#18

Thanks reidab,
I've tweaked sometime with your hack and put a zenphoto badge on my site.

See you,
l.

Member
Member
3stripe   22-02-2006, 20:08
#19

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 :-(

Member
Member
3stripe   03-04-2006, 18:09
#20

Can anyone possibly help me with this if they have a moment?

I need to recode this to give 2 kinds of output:

  1. Flickr style square thumbnails x4 in a sidebar
  2. A large square image on the homepage, which is a scaled crop of the fullsize image.

Many thanks

James
PS. No-one ever answers my posts

Pages (4): 1 2 3 4   
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.