diff --git a/controllers/front/page.php b/controllers/front/page.php index 7d12706..ef0b208 100644 --- a/controllers/front/page.php +++ b/controllers/front/page.php @@ -99,12 +99,13 @@ public function initContent() $this->everblockPage = $page; + $coverImageData = $page->getCoverImageData($this->context); + $this->context->smarty->assign([ 'everblock_page' => $page, 'everblock_page_content' => $renderedContent, - 'everblock_page_image' => $page->cover_image - ? $this->context->link->getMediaLink(_PS_IMG_ . 'pages/' . $page->cover_image) - : '', + 'everblock_page_image' => $coverImageData['url'] ?? '', + 'everblock_page_image_data' => $coverImageData, 'everblock_page_author' => $authorData, 'everblock_structured_data' => $this->buildItemListStructuredData($pages, $pageLinks), 'everblock_prettyblocks_enabled' => $isPrettyBlocksEnabled, diff --git a/src/Service/EverblockTools.php b/src/Service/EverblockTools.php index 2d3ed26..8342e48 100644 --- a/src/Service/EverblockTools.php +++ b/src/Service/EverblockTools.php @@ -5507,6 +5507,21 @@ public static function fetchInstagramImages() } } + $width = 0; + $height = 0; + if (is_file($filePath)) { + $imageSize = @getimagesize($filePath); + if ($imageSize) { + $width = (int) $imageSize[0]; + $height = (int) $imageSize[1]; + } + } + + if ($width <= 0 || $height <= 0) { + $width = 320; + $height = 320; + } + $imgs[] = [ 'id' => isset($post['id']) ? $post['id'] : $post['id'], 'permalink' => isset($post['permalink']) ? $post['permalink'] : '', @@ -5515,6 +5530,8 @@ public static function fetchInstagramImages() 'standard_resolution' => $webPath, 'caption' => isset($post['caption']) ? $post['caption'] : '', 'is_video' => strpos($mediaUrl, '.mp4') !== false, + 'width' => $width, + 'height' => $height, ]; } } diff --git a/views/templates/front/page.tpl b/views/templates/front/page.tpl index 2123609..79e8508 100644 --- a/views/templates/front/page.tpl +++ b/views/templates/front/page.tpl @@ -4,9 +4,14 @@

{$everblock_page->title|default:''}

- {if $everblock_page_image} + {if !empty($everblock_page_image_data.url)}
- {$everblock_page->title|default:''|escape:'htmlall':'UTF-8'} + {$everblock_page->title|default:''|escape:'htmlall':'UTF-8'}
{/if} {if $everblock_page->short_description} diff --git a/views/templates/hook/instagram.tpl b/views/templates/hook/instagram.tpl index 59b8a60..d2c8689 100644 --- a/views/templates/hook/instagram.tpl +++ b/views/templates/hook/instagram.tpl @@ -35,6 +35,8 @@ src="{$img.thumbnail|escape:'quotes':'UTF-8'}" alt="{$img.caption|escape:'html':'UTF-8'}" loading="lazy" + width="{$img.width|intval}" + height="{$img.height|intval}" />