Sorry, this page is only available in one language

RandomOrderImages

Suggested dropletname: RandomOrderImages

Published by: rsmith

Get random images from a folder in the MEDIA folder.
Will use thumbnail images if available (folder/thumbs/file.ext.thumb.jpg)(currently generated by Another Image Gallery)

$folder=opendir(WB_PATH.MEDIA_DIRECTORY.'/'.$dir.'/.'); 
$names = array();
while ($file = readdir($folder))  {
	$ext=strtolower(substr($file,-4));
	if ($ext==".jpg"||$ext==".gif"||$ext==".png"){
		$names[count($names)] = $file; 
	}
}
closedir($folder);
shuffle($names);
reset($names);
array_unshift($names," ");
if(isset($width)){$width=' width="'.$width.'"';}else{$width="";}
if(isset($height)){$height=' height="'.$height.'"';}else{$height="";}
$count=1;
while(($image=next($names))and(($count<=$num)or(!isset($num)))){
$name=substr($image,0,-4);
if($link=="y"){$images=$images.'<a href="'.WB_URL.MEDIA_DIRECTORY.'/'.$dir.'/'.$image.'" target=_blank>';}
if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/'.$dir.'/thumbs/'.$image.'.thumb.jpg')){
$images=$images.'<img src="'.WB_URL.MEDIA_DIRECTORY.'/'.$dir.'/thumbs/'.$image.'.thumb.jpg" alt="'.$name.'" '.$width.$height.' border=0"/>';
}else{
$images=$images.' <img src="'.WB_URL.MEDIA_DIRECTORY.'/'.$dir.'/'.$image.'" alt="'.$name.'" '.$width.$height.' ">';
}
if($link=="y"){$images=$images.'</a>';}
$count++;
}
return $images;

Required parameter

dir=(subfolder_in_mediafolder)

Optional parameters

width=(width)
height=(height)
link(y=yes)
num=(number to display)

Example

[[RandomOrderImages?dir=myimages]]



« Previous droplet | Overview | Next droplet »