public function transformImageTags($p_match)
{
array_shift($p_match);
$attrs = array();
foreach ($p_match as $attr) {
$attr = explode('=', $attr);
if (isset($attr[0]) && !empty($attr[0])) {
$attrName = trim(strtolower($attr[0]));
if (isset($attr[1]) && count($attr) > 2) {
$attrValue = implode('=', array_slice($attr, 1));
} else {
$attrValue = isset($attr[1]) ? $attr[1] : '';
}
// Strip out the quotes
$attrValue = str_replace('"', '', $attrValue);
$attrs[$attrName] = $attrValue;
}
}
if (!isset($attrs['id'])) {
return '';
} else {
if (strpos($attrs['id'], '_')) {
list($templateId, $imageRatio) = explode('_', $attrs['id']);
} else {
$templateId = $attrs['id'];
}
$articleImage = new ArticleImage($this->m_data['NrArticle'], null, $templateId);
if (!$articleImage->exists()) {
return '';
}
}
$alignTag = '';
if (isset($attrs['align'])) {
$alignTag = 'align="' . $attrs['align'] . '"';
}
$altTag = '';
if (isset($attrs['alt']) && strlen($attrs['alt']) > 0) {
$altTag = 'alt="' . $attrs['alt'] . '"';
}
$captionTag = '';
if (isset($attrs['title']) && strlen($attrs['title']) > 0) {
$captionTag = 'sub="' . $attrs['title'] . '"';
}
if (isset($attrs['width']) && strlen($attrs['width']) > 0) {
$widthTag = 'width="' . $attrs['width'] . '"';
}
if (isset($attrs['height']) && strlen($attrs['height']) > 0) {
$heightTag = 'height="' . $attrs['height'] . '"';
}
$ratioTag = '';
if (isset($imageRatio) && ($imageRatio > 0 && $imageRatio < 100)) {
$ratioTag = 'ratio="' . $imageRatio . '"';
}
$imageTag = "<!** Image {$templateId} {$alignTag} {$altTag} {$captionTag} {$widthTag} {$heightTag} {$ratioTag}>";
return $imageTag;
}