Get Placeholder image url in Magento 2.

Native Magento 2 has four types of placeholder image called, small_image, image, thumbnail, and swatch_image.

Placeholder image URL used when you want to display default images for a site.
Magento 2 get placeholder image URL using below simple code snippet.

I hope you are aware of, How to upload Placeholder images in Magento 2?

Create Block file to programmatically get placeholder image,

Call Placeholder function from Template file by below way,

Using the above way, You can get small_image Placeholder image url in Magento 2.
You can pass small_image, image, thumbnail and swatch_image for a placeholder.

One Reply to “Get Placeholder image url in Magento 2.”

Leave a Reply

Your email address will not be published. Required fields are marked *