1

I want to display my new product image type in my phtml.

I use :

echo $block->getImage($product, "custom_type_image")->toHtml()

That work, but all my product didn't have an image with this type, so I would like, if no image was found, that display default image like :

echo $block->getImage($product, "product_base_image")->toHtml()

How to check ?

I can't check

if $block->getImage($product, "custom_type_image")->toHtml() 

is null because, if it doesn't succeed to find my picture, it create one as custom_type_image.jpg (which doesn't exist, so the picture is broken)

2
  • 1
    what if you check $product->getCustomTypeImage(); ?
    – Pawan
    Apr 15, 2019 at 16:48
  • Indeed, it was easy but I did'nt think about this method, thank you !
    – Kozame
    Apr 16, 2019 at 7:47

1 Answer 1

0

You check it by $product->getCustomTypeImage();

As it is a product attribute, it will give you value.

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.