Member
Member
pluto459   2007-04-07, 11:04
#1
I want to set up the random image to only pull from one album instead of from them all.
Is it possible and how do i do it Smile

Thanks
Member
Member
antoxa   2007-04-08, 09:14
#2
paste it at the end of your zen/functions.php file before ?> and add <? random_image("your album title"); ?> to your template Wink

`

function random_image($albumtitle){

$size = '_'.zp_conf('thumb_size').'_cw'.zp_conf('thumb_crop_width').'_ch'.zp_conf('thumb_crop_height');

$albums = mysql_query("select * from ".prefix('albums')." as albums where albums.title= '".$albumtitle."'");

while($a = mysql_fetch_array($albums)) {

$album_id = $a['id'];

$album = $a['folder'];

}

$image = mysql_query("select * from ".prefix('images')." as images where images.albumid = $album_id ORDER BY RAND() LIMIT 1");

while($i = mysql_fetch_array($image)) {

$filename = $i['filename'];

$desc = $i['title'];

}

if (zp_conf('mod_rewrite') == false) {

echo '';

} else {

echo '<a href="'.WEBPATH.'/'.$album.'/'.$filename.'" title="'.$desc.'">';

}

echo '[img]'.WEBPATH.'/cache/'.$album.'/'.$filename.$size.'.jpg[/img]';

}

`
Member
Member
dobiho   2007-04-10, 14:13
#3
I'd like to show zenphoto random image on wordpress sidebar. how can I get it?
Member
Member
thinkdreams   2007-04-10, 17:08
#4
dobiho-

you can try the zenshow plugin for wordpress. It still exists at http://www.zenphoto.org/trac/wiki/ZenphotoPlugins (look for it at the attachments on the bottom of the page). It may still be available at http://www.ruicruz.com/index.php/zenshow/ with some instructions (last I checked)

It seems to work OK for me on my current wordpress and zenphoto implementation.
Member
Member
PierreSnugg   2008-04-28, 08:11
#5
Hy, i tried setting up your code (zenphoto1.1.5) but i get an error showing up:

Fatal error:
Call to undefined function: zp_conf() in /homepages/.../zp-core/functions.php on line 1891

or is there another way around to get a rendom image from a specific album. curently i´m using this in my index.php:
`

<?php $randomImage = getRandomImages(); $randomImageURL = getURL($randomImage); print

"<img src='".$randomImage->getSizedImage('400')."' alt='".$randomImage->getTitle()."'/>"; ?>

`

that works fine, unless i need a random image from
specific album...

can somebody help?
Administrator
Administrator
acrylian   2008-04-28, 08:32
#6
That code you are trying to use is old, we don't use the variable $zp_conf anymore.

We have already a functions for that build in version 1.1.5. Take a look on the functions guide www.zenphoto.org/documentation-official
Member
Member
PierreSnugg   2008-04-28, 08:55
#7
Ok, thanx - i replaced:

`

<?php $randomImage = getRandomImages(); $randomImageURL = getURL($randomImage); print

"<img src='".$randomImage->getSizedImage('400')."' alt='".$randomImage->getTitle()."'/>"; ?>

`

with

`

<?php $randomImage = getRandomImagesAlbum("Album1"); $randomImageURL = getURL($randomImage); print

"<img src='".$randomImage->getSizedImage('400')."' alt='".$randomImage->getTitle()."'/>"; ?>

`

works great!

THX
Member
Member
sevenupcan   2008-04-28, 11:12
#8
With this code is it possible to put the album title and description below the image?
Member
Member
PierreSnugg   2008-04-28, 14:06
#9
And what also would be interesting, is how to put a link on that to the image that´s shown by the random function... i tried "getRandomImageURL" etc. i don´t get it worky?
Administrator
Administrator
acrylian   2008-04-28, 14:32
#10
`printRandomImages()` itself prints thumbnails with links...
Member
Member
PierreSnugg   2008-04-28, 15:19
#11
but i just need the link function for the already shown image, i don´t use random thumbnails...
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.