I use Geeklog Weblog with 4images photo gallery.
A user named Lacy created a simple image randomizer that displays a random thumbnail from 4images into Geeklog. Here is Lacy's code for the randomizer:
// RANDOM IMAGE FUNCTION
function phpblock_rand4image() {
global $_CONF, $_USER, $_TABLES;
$imgdir = "gallery";
$title_limit = 30;
$dscp_limit = 50;
// DATABASE
$rand_sql = DB_query("SELECT image_id,cat_id,image_name,image_description,image_thumb_file FROM 4images_images WHERE (image_thumb_file!='')ORDER BY RAND(NOW()) LIMIT 1");
$num = DB_numRows($rand_sql);
if ($num == 0) {
$rand .= '<br/><center>No images exist yet!</center><br/>';
} else {
$A = DB_fetchArray($rand_sql);
$album = DB_getItem("4images_categories",cat_name,"cat_id=$A[cat_id]");
if(strlen ($A['image_name']) > $title_limit){
$A['image_name'] = substr($A['image_name'], 0, $title_limit);
$A['image_name'] .= "..";
}
$rand .='<table width="98%"><td width="100%">';
$rand .='<center><a href="' .$_CONF['site_url']. '/' .$imgdir. '/details.php?image_id=' .$A['image_id']. '">';
$rand .='<img src="' .$_CONF['site_url']. '/' .$imgdir. '/data/thumbnails/' .$A['cat_id']. '/' .$A['image_thumb_file']. '" alt="' .$A['image_name']. '" style="border: 1 solid #000000;"><br>';
$rand .=$A['image_name'];
$rand .='</a></center>';
$rand .='<br>Album: <a href="' .$_CONF['site_url']. '/' .$imgdir. '/categories.php?cat_id=' .$A['cat_id']. '">' .$album. '</a>';
$rand .='</td></table>';
return $rand;
}
}
For some dumb reason when I integrated 4images with Geeklog, I put my 4images directory inside of an unessesary directory.
So my address to my photo album is www.mysite.com/mypics/4images/index.php, when it should be www.mysite.com/4images/index.php
Everything worked fine up until when I tried to apply the code for showing a random image. Since I have an extra folder, the random image code sends the user to
http://www.mysite.com/public_html/gallery/details.php?image_id=8
instead of
http://www.mysite.com/mypics/4images/details.php?image_id=8
My photo album still works, I simply can't get the randomizer code to call on my directory.
What is the best way to alter the code to work with my extra /mypics/directory?
Let me know if this is too confusing :queasy: