Hotfix: Falls in einer News ein (floating!) imgTag dabei ist, wird

auch versucht, die Attribute width und height zu extrahieren. Vom
Standardformat 200x133 abweichende Formate können nun auch in der
ampSeite richtig skaliert werden, müssen dafür aber in der Nachricht
in der Datenbank auch mit width und height Attribut eingetragen sein!

On branch redesign2018

Changes to be committed:
	modified:   phpLib/cwsvJudo/newsLib.php
This commit is contained in:
marko
2018-07-04 12:58:25 +02:00
parent f3bce58dbb
commit 0539f1edd5

View File

@@ -99,6 +99,8 @@ $options = getKeyValueArray($someOptions);
foreach($anchor->getElementsByTagName('img') as $img){
$aNews['promoImg']['src'] = $img->getAttribute('src');
$aNews['promoImg']['alt'] = $img->getAttribute('alt');
$aNews['promoImg']['width'] = $img->getAttribute('width');
$aNews['promoImg']['height'] = $img->getAttribute('height');
$anchorDad->removeChild($anchor);
break;
}
@@ -128,7 +130,7 @@ $options = getKeyValueArray($someOptions);
// Für den Fall einer ampSeite müssen die imgTags angepasst werden
if( strpos( $_SERVER['ORIG_PATH_TRANSLATED'], "pages/amp" ) !== false ){
$retHtml = str_replace("<img", "<amp-img layout=\"responsive\" width=\"200\" height=\"133\"", $retHtml);
$retHtml = str_replace("<img", "<amp-img layout=\"responsive\" width=\"".($aNews['promoImg']['width']?$aNews['promoImg']['width']:"200")."\" height=\"".($aNews['promoImg']['height']?$aNews['promoImg']['height']:"133")."\"", $retHtml);
$retHtml = str_replace("/>", "></amp-img>", $retHtml);
}
}