Empty ALT description not working in 1.28?
Empty ALT description not working in 1.28?
In 1.25 dev you could create an empty ALT description for unimportant images by using two pipes in the caption field (||). This doesn't seem to work in 1.28. Is there a file I can hack to get this function back?
NOT a "bug" by the way!
"1.2.8 changelog.txt"
Untested - But removing "comment" characters ( // ) from -old- function and adding to -new- MAY work:
"content.article.inc.php"
1.2.6
1.2.8
"1.2.8 changelog.txt"
"front.func.inc.php"[ADD] New function getImageCaption($caption[, $array_index='NUM'||'STRING']): returns an array containing all caption elements.
Code: Select all
function getImageCaption($caption='', $array_index='NUM') {
// splits given image caption and returns an array
$caption = explode('|', $caption);
// following is default for the exploded $caption
// [0] caption text
// [1] alt text for image
// [2] link -> array(0 => link, 1 => target)
// [3] title text -> if empty alt text will be used
$caption[0] = trim($caption[0]);
$caption[1] = isset($caption[1]) ? trim($caption[1]) : '';
$caption[2] = isset($caption[2]) ? explode(' ', trim($caption[2])) : array(0 => '', 1 => '');
$caption[2][0] = trim($caption[2][0]);
if(empty($caption[2][0]) || empty($caption[2][1])) {
$caption[2][1] = '';
} else {
$caption[2][1] = trim($caption[2][1]);
$caption[2][1] = empty($caption[2][1]) ? '' : ' target="'.$caption[2][1].'"';
}
$caption[3] = isset($caption[3]) ? trim($caption[3]) : $caption[1];
if($array_index == 'NUM') {
return $caption;
} else {
return array( 'caption_text' => $caption[0], 'caption_alt' => $caption[1],
'caption_link' => $caption[2][0], 'caption_target' => $caption[2][1],
'caption_title' => $caption[3] );
}
}
"content.article.inc.php"
1.2.6
Code: Select all
//retrieve image info
$row["article_image"] = unserialize($row["article_image"]);
$caption = explode('|', $row["article_image"]["caption"]);
$row["article_image"]["caption"] = $caption[0]; //$caption[0]
Code: Select all
//retrieve image info
$row["article_image"] = unserialize($row["article_image"]);
//$caption = explode('|', $row["article_image"]["caption"]);
$caption = getImageCaption($row["article_image"]["caption"]);
$row["article_image"]["caption"] = $caption[0]; //$caption[0]
OK. Fixed it. I modified the conditional statement(s) that use the filename for the 'alt' description if left blank. With the following hack, if you don't enter a specific description you now get alt="".
front.func.inc.php
line 251 replace:
with:
line 418 replace:
with:
I appreciate there may be a better way of changing those functions, but this seems to work (for those that prefer it).
front.func.inc.php
line 251 replace:
Code: Select all
$caption[1] = empty($caption[1]) ? html_specialchars($image[1]) : html_specialchars($caption[1]);
Code: Select all
$caption[1] = empty($caption[1]) ? html_specialchars($caption[1]) : html_specialchars($caption[1]);
Code: Select all
$caption[1] = empty($caption[1]) ? htmlentities($imagelist['images'][$key][1]) : html_specialchars($caption[1]);
Code: Select all
$caption[1] = empty($caption[1]) ? html_specialchars($caption[1]) : html_specialchars($caption[1]);