Merge pull request #80 from bifek/fixrssfn

fix a tiny bug where imageName would've been assigned to the last file...
This commit is contained in:
Tom.C. 2014-11-27 07:35:58 +01:00
commit a7719c012c

View file

@ -58,25 +58,34 @@ if (!function_exists('exif_read_data') && $display_exif == 1) {
function padstring($name, $length) function padstring($name, $length)
{ {
global $label_max_length; global $label_max_length;
if (!isset($length)) if (!isset($length)) {
$length = $label_max_length; $length = $label_max_length;
if (strlen($name) > $length) }
if (strlen($name) > $length) {
return substr($name, 0, $length) . "..."; return substr($name, 0, $length) . "...";
}
return $name; return $name;
} }
function getfirstImage($dirname) function getfirstImage($dirname)
{ {
$imageName = false; $imageName = false;
$ext = array("jpg", "png", "jpeg", "gif", "JPG", "PNG", "GIF", "JPEG"); $extensions = array("jpg", "png", "jpeg", "gif");
if ($handle = opendir($dirname)) { if ($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))) { while(false !== ($file = readdir($handle))) {
$lastdot = strrpos($file, '.'); if ($file[0] == '.') {
$extension = substr($file, $lastdot + 1); continue;
if ($file[0] != '.' && in_array($extension, $ext)) }
$pathinfo = pathinfo($file);
if (empty($pathinfo['extension'])) {
continue;
}
$ext = strtolower($pathinfo['extension']);
if (in_array($ext, $extensions)) {
$imageName = $file;
break; break;
}
} }
$imageName = $file;
closedir($handle); closedir($handle);
} }
return $imageName; return $imageName;