initial commit
This commit is contained in:
50
production/php/functions/func_images.php
Executable file
50
production/php/functions/func_images.php
Executable file
@@ -0,0 +1,50 @@
|
||||
<?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>";
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user