Fix getting style attribute in the image block

In some cases wasn't the style attribute set and it caused type error in calling method for parsing styles.
[MAILPOET-5688]
This commit is contained in:
Jan Lysý
2023-12-11 17:37:01 +01:00
committed by Rostislav Wolný
parent 1b94347bb4
commit 2ce746a156

View File

@ -41,7 +41,7 @@ class Image implements BlockRenderer {
$html = new \WP_HTML_Tag_Processor($blockContent);
if ($html->next_tag(['tag_name' => 'img'])) {
// Getting height from styles and if it's set, we set the height attribute
$styles = $html->get_attribute('style');
$styles = $html->get_attribute('style') ?? '';
$styles = $settingsController->parseStylesToArray($styles);
$height = $styles['height'] ?? null;
if ($height && is_numeric($settingsController->parseNumberFromStringWithPixels($height))) {