Member
Member
websat   2006-07-01, 18:51
#1
Hi
I want to display a random pics from zenphoto gallery on my website, how i can do that ???
Member
Member
thinkdreams   2006-07-01, 20:02
#2
Websat-

Does your website run Wordpress, as there is a nifty plugin for Wordpress that allows you to display photos called Zenshow. Otherwise, you may have to code a routine to grab the random images from the database and display them. I have a random function that works within Zenphoto. Let me see if it can modified to work in your scenario.

Thinkdreams.
Member
Member
websat   2006-07-01, 20:36
#3
hi
Thanks for your answer, my website don't use wordpress, i made it myself using php (includes)
Member
Member
thinkdreams   2006-07-01, 20:39
#4
Cool. You should share it on the forums so others may benefit from your code.

Smile
Member
Member
websat   2006-07-01, 20:46
#5
ok, the main page is index.php who include with a menu other page named page-name.inc.php, the code for index.php is here: http://test.websat-telecom.com/index.php.txt
The code for the page where i want to have a random pic from zenphoto is here: http://test.websat-telecom.com/index.inc.php.txt

thanks for your help
Member
Member
websat   2006-07-03, 09:02
#6
nobody can help me ???
Member
Member
thinkdreams   2006-07-03, 12:18
#7
Patience please websat. We all have jobs, and are busy. I'm working with some ideas, but I have to work around my work schedule (8-5 M-F) and my personal responsibilities. We are all here on a voluntary basis. Others on the forum are under the same constraints I'm sure. So in other words, it may take time to get an answer to you, but if I don't someone else may have a quicker answer.
Member
Member
thinkdreams   2006-07-03, 12:19
#8
And those two links listed above to the php code of your website are not valid right now.
Member
Member
websat   2006-07-03, 12:31
#9
Ok, no problems thanks for your answer and your help, the links are now here:
The code for the index
http://www.websat-telecom.com/index.php.txt

The code for the page where i want to have a random pic from zenphoto is here: http://www.websat-telecom.com/index.inc.php.txt
Member
Member
thinkdreams   2006-07-03, 17:19
#10
I can probably give you a push in the right direction. Take a look at Zenshow, a plugin designed to pull random images from the Zenphoto DB within Wordpress. There is a function in the code that deals with random photos. You may be able to rework that code to your needs, as it is just a SQL query to the zenphoto DB. That would be my suggestion on where to start. You can obtain Zenshow from a link somewhere on the wiki.

That should get you started.
Member
Member
websat   2006-07-04, 11:10
#11
thanks for your help, i try this code for random.php:

<?php
require_once('classes.php');

$imageSize = (isset($_GET['s']) ? $_GET['s'] : 150);
$randomImage = getRandomImage();
$imageLinkURL = getImageLinkURL($randomImage);

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

function getRandomImage() {
global $_zp_current_image;
if(db_connect()) {
$random=query_single_row('SELECT images.filename, images.title, albums.folder FROM images INNER JOIN albums ON images.albumid = albums.id ORDER BY RAND() LIMIT 1');
$image = new Image(new Album(new Gallery(), $random['folder']), $random['filename']);

return $image;

} else {
return false;
}
}

function getImageLinkURL($image) {
if (zp_conf('mod_rewrite')) {
return WEBPATH . "/" . urlencode($image->getAlbumName()) . "/" . urlencode($image->name);
} else {
return WEBPATH . "/index.php?album=" . urlencode($image->getAlbumName()) . "&image=" . urlencode($image->name);
}
}
?>

and put that in the page where i want to see the random pic:
code
<?php include("http://galerie.websat-telecom.com/zen/random.php"); ?>
code

it don't work, in the page the link url is false:
http://www.websat-telecom.com/zen/zen/i.php?a=pi6alk-mast&i=Dsc05486.jpg&s=150

the good url must be: http://galerie.websat-telecom.com/zen/i.php?a=pi6alk-mast&i=Dsc05486.jpg&s=150
Member
Member
websat   2006-07-04, 11:58
#12
ok, it's work now, thanks for your help..
Junior Member
Junior Member
Danloreye   2006-07-06, 08:39
#13
Will a wordpress widget of zenshow be released ?

I've designed one but i had to remove a line in the connect() function to allow the widget to be used.

this one:
header('Content-Type: text/html; charset=ISO-8859-1');
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.