I'm getting image for Open Graph protocol with following code:

<meta property="og:image" content="<?php echo $block->escapeUrl($block->getImage($block->getProduct(), 'product_base_image')->getImageUrl()); ?>" />

But it gives me the small image with 80x80px size:

<meta property="og:image" content="https://example.com/pub/media/catalog/product/cache/image/80x80/beff4985b56e3afdbeabfc89641a4582/0/1/01.jpg">

Now I have such folder structure:

enter image description here

How can I get the other size from this folder or non cached images?

  • In you theme etc/view.xml find image id product_base_image and check the image type, if this select image id that type will be image, if type is small_image change to image If type is image only then respective size (width & height) will 80*80 change that one to a proper size as you required. and flush cache and check respective product detail page. Commented Apr 22, 2018 at 16:56
  • What is the file path of the xml that you're talking about Kanhaiya? Commented Dec 21, 2018 at 15:11

1 Answer 1


Try the following code:

$imagehelper = $this->helper('Magento\Catalog\Helper\Image');
$ogImage = $imagehelper->init($block->getProduct(), 'product_base_image')
                       ->resize(250, 250)

<meta property="og:image" content="<?php echo $ogImage; ?>" />
  • Does this just increase the small image size (i.e. won't it lose resolution)? Commented Dec 21, 2018 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.