Adding functions to retrieve all files from a directory into an array :
- get_picture_files : returns an array with all picture files according to $conf['picture_ext'] - get_thumb_files : returns an array with all thumbnails according to $conf['picture_ext'] and $conf['prefix_thumbnail'] git-svn-id: http://piwigo.org/svn/branches/release-1_3@277 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
0fa0c8bb07
commit
1c59964dff
1 changed files with 52 additions and 1 deletions
|
@ -54,6 +54,57 @@ function is_image( $filename, $create_thumbnail = false )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns an array with all picture files according to $conf['picture_ext']
|
||||||
|
*
|
||||||
|
* @param string $dir
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function get_picture_files( $dir )
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$pictures = array();
|
||||||
|
if ( $opendir = opendir( $dir ) )
|
||||||
|
{
|
||||||
|
while ( $file = readdir( $opendir ) )
|
||||||
|
{
|
||||||
|
if ( in_array( get_extension( $file ), $conf['picture_ext'] ) )
|
||||||
|
{
|
||||||
|
array_push( $pictures, $file );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $pictures;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns an array with all thumbnails according to $conf['picture_ext']
|
||||||
|
* and $conf['prefix_thumbnail']
|
||||||
|
*
|
||||||
|
* @param string $dir
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function get_thumb_files( $dir )
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$prefix_length = strlen( $conf['prefix_thumbnail'] );
|
||||||
|
|
||||||
|
$thumbnails = array();
|
||||||
|
if ( $opendir = @opendir( $dir ) )
|
||||||
|
{
|
||||||
|
while ( $file = readdir( $opendir ) )
|
||||||
|
{
|
||||||
|
if ( in_array( get_extension( $file ), $conf['picture_ext'] )
|
||||||
|
and substr($file,0,$prefix_length) == $conf['prefix_thumbnail'] )
|
||||||
|
{
|
||||||
|
array_push( $thumbnails, $file );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $thumbnails;
|
||||||
|
}
|
||||||
|
|
||||||
function TN_exists( $dir, $file )
|
function TN_exists( $dir, $file )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue