Random Image Problem
Random Image Problem
I have the latest download of CMS
and am using the random_image tag The problem am having is I randomly get a red X image. When clicking properties is shows
/images
This is the code I have in the template is
With 8 images...
Site can be seen here
http://64.128.95.108/~custerco/index.php
The big image
The images are in a folder like this images/front
For the life of my I cannot troubleshoot this issue, can anyone help??
Thanks!
Cori
and am using the random_image tag The problem am having is I randomly get a red X image. When clicking properties is shows
/images
This is the code I have in the template is
With 8 images...
Site can be seen here
http://64.128.95.108/~custerco/index.php
The big image
The images are in a folder like this images/front
For the life of my I cannot troubleshoot this issue, can anyone help??
Thanks!
Cori
Re: Random Image Problem
Looks like it's working for me.. a new image on every refresh... 

-
- Forum Members
- Posts: 65
- Joined: Tue May 22, 2007 10:05 pm
Re: Random Image Problem
Just so you don't think you are going mad, I am getting the red X randomly as well! Maybe it is a browser based problem. I am using IE7 on XP
Re: Random Image Problem
I get the red X on IE and Firefox.... I hoping that having alot of photo will minimize the occurrence... but it still comes up!
Re: Random Image Problem
when the image is red, view source code and paste it here, so we can help you
Re: Random Image Problem
I just tested on 3 pc across 6 browses and all came out fine... did 10 refreshes each... never one red x... for what it's worth.
viebig is right we need some code from when it's in error... sorry I can't be more helpful.
Jeremy
viebig is right we need some code from when it's in error... sorry I can't be more helpful.
Jeremy
Re: Random Image Problem
It looks like the random image generator is including the "parent directory" in the file list of the images/front directory, on a broken page I see:
where on all the good pages I get something like:
You need to exclude the folder ".." (parent directory) somehow...
Great looking site BTW.
Code: Select all
<img src="images/front/..">
Code: Select all
<img src="images/front/picture_one_foot.jpg">
Great looking site BTW.
May the wind allways be on your back, and the sun allways on your face.
Re: Random Image Problem
Thanks! How would I edit that to excluded? Copy of plugin code attached
read() ) {
++$count;
}
$myDir->close();
$myDir = dir($dirn);
rewinddir();
srand(time());
$randnum = rand(3,($count-2)+1);
for($i=0;$iread();
$myimage = $entryName;
}
return $dirn . "/" . $myimage;
}
function smarty_cms_help_function_random_image() {
?>
What does this do?
Grabs a random image from the image directory specified
How do I use it?
Just insert the tag into your template/page like: {random_image dir="images/albums"}
What parameters does it take?
(optional)dir - directory containing the images.
Author: Robert Campbell<rob@techcom.dyndns.org>
Version: 1.0
Change History:
None
Re: Random Image Problem
I see... I will send you an UDT, containing a simplified as faster version of random_image tag
Re: Random Image Problem
I see... I will send you an UDT, containing a simplified as faster version of random_image tag
ok sounds wonderful, I am new here, how will that be sent? thanks for all your help!!!
Corisa
Re: Random Image Problem
viebig, can you send me the UDT as well? I am having the same problems with that extension with CMSMS 1.5.2
Re: Random Image Problem
Hello people!
name it rnd_image
we have two optional params:
dir - directory where the files are
exclude - a simple exclude string
the usage is
This will get a random image from 'uploads/images/random' folder, excluding all images that have 'thumb' on the file name
Also only .jpeg, .jpg, .gif and .png are indexed, so the dir can contain another files too. Directories, '.' and '..' will not get indexed.
So, try it, let me know if it works for you and if it has bugs(I didnt test it)
Cheers, and applaud me!
name it rnd_image
Code: Select all
$dir = (empty($params['dir'])) ? "uploads/images" : $params['dir'];
$myDir = dir($dir);
if(!$myDir) return "<!-- Directory '".$params['dir']."' not exist, aborting -->";
$images = Array();
while($file = $myDir->read()) {
if($file != '.' && $file != '..' && !is_dir($params['dir'].$file)) {
$ext = strtolower(substr(strrchr($file, "."), 1));
if(($ext == "jpg" || $ext == "jpeg" || $ext == "gif" || $ext == "png") && strstr($file, $params['exclude']) == "") {
$images[] = $file;
}}}
$myDir->close();
if (sizeof($images) == 0) return "<!-- No images found matching image extensions and excluded pattern -->";
return $dir.'/'.$images[rand(0,sizeof($images)-1)];
dir - directory where the files are
exclude - a simple exclude string
the usage is
Code: Select all
{rnd_image dir="uploads/images/random" exclude="thumb"}
Also only .jpeg, .jpg, .gif and .png are indexed, so the dir can contain another files too. Directories, '.' and '..' will not get indexed.
So, try it, let me know if it works for you and if it has bugs(I didnt test it)
Cheers, and applaud me!
Last edited by viebig on Sun Mar 01, 2009 5:17 am, edited 1 time in total.