I created a custom image attribute in admin panel (image_big) to show a specific image as a background in single product page, but I am not being able to fetch it inside the Block Class or phtml file.


    namespace MyVendor\ImageBig\Block;

    class ProductBigImage extends \Magento\Catalog\Block\Product\View\AbstractView


// $product = $block->getProduct()->getId(); // this works I get the correct ProductID
$product = $block->getProduct();
$productImageAttr = $product->getCustomAttribute( 'image_big' );
$productImage = $this->helper('Magento\Catalog\Helper\Image')
    ->init($product, 'image_big')

What am I doing wrong?


  • 1
    NVM. Solved, I had to fetch it with ->getUrl() – Mauro Oct 3 '17 at 21:45
  • Please Put it as answer,So in future other people will get help from your – Amit Bera Oct 4 '17 at 3:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.