50 lines
1.5 KiB
PHP
Executable File
50 lines
1.5 KiB
PHP
Executable File
<?php
|
|
#################################################################################
|
|
# #
|
|
# written by benjamin ramey #
|
|
# bsr@rameydesign.net #
|
|
# #
|
|
# This file contains: #
|
|
# Functions that govern various images process, such at #
|
|
# grabbing a random one from a give folder, etc #
|
|
# #
|
|
#################################################################################
|
|
|
|
################################################### FUNCTION: images_get_random #
|
|
function images_get_random($folders,$num = 1,$patt = "/.(jpg)|(JPG)/")
|
|
{
|
|
$images = array();
|
|
$folder_info = array();
|
|
$num_folders = count($folders);
|
|
|
|
# get the pictures for each folder
|
|
foreach($folders as $key => $value)
|
|
{
|
|
$folder_info[$key]['name'] = $value;
|
|
$folder_info[$key]['pictures'] = filesys_get_wanted_children($value,'folders',$patt);
|
|
}
|
|
|
|
# get pictures until we have enough!
|
|
for($k = 0; $k < $num; $k++)
|
|
{
|
|
$folder = $folder_info[array_rand($folder_info)];
|
|
$image = $folder['pictures'][array_rand($folder['pictures'])];
|
|
array_push($images,$folder['name'].'/'.$image);
|
|
}
|
|
|
|
return($images);
|
|
}
|
|
|
|
################################################# FUNCTION: images_print_strip #
|
|
function images_print_strip($images,$absPath)
|
|
{
|
|
print "<div id='image-strip'>\n";
|
|
foreach($images as $image)
|
|
{
|
|
$image = str_replace($absPath,'',$image);
|
|
print "<img src='$image' />\n";
|
|
}
|
|
print "</div>";
|
|
}
|
|
|
|
?>
|