Extract nested img element more safely

[MAILPOET-1684]
This commit is contained in:
Jan Jakeš
2019-01-07 18:05:56 +01:00
parent 0c7c725629
commit 4d97a2f6a7

View File

@@ -41,7 +41,7 @@ class StructureTransformer {
private function transformTagsToBlocks($root, $image_full_width) {
return array_map(function($item) use ($image_full_width) {
if($item->tag === 'img' || $item->tag === 'a' && $item->query('img')) {
$image = $item->tag === 'img' ? $item : $item->children[0];
$image = $item->tag === 'img' ? $item : $item->query('img')[0];
$width = $image->getAttribute('width');
$height = $image->getAttribute('height');
return array(