The $file variable holds the filename only; $base_image has the subfolder (if any) plus filename.This code will handle any file (as long as it doesn't have spaces), and put the text above or below the image (depending on the value of a constant ADDIMG_TEXT_TOP which should be set in the definitions file):
PHP Code:
// additional image titles
$badchars = array('/','\\','.','-',' ');//not allowed in constant names
// if any other characters could be used in filepath, add them to $badchars
$add_const_name = 'ADDIMG_' . strtoupper(str_replace($badchars,'_',$base_image));
if (defined($add_const_name)) {//add text above or below images
$link = (ADDIMG_TEXT_TOP)? '<div class="addImgTitle">' . constant($add_const_name) . '</div>' . $link: $link . '<div class="addImgTitle">' . constant($add_const_name) . '</div>';
}
// /additional image titles
// List Box array generation:
Add to the definition file:
PHP Code:
define ('ADDIMG_TEXT_TOP','true'};//change to false to put text below images
The $badchars setup is intended to convert spaces, but apparently is unable to do so. It will handle / \ . - characters.