cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to show meida image on frontend

Former Member
0 Kudos
528

In impex file, I create a mediamodel entry, which is a png file.

Would I know if there is any example how to show this media model on frontend?

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Guangwei

Have a look at the AbstractProductImagePopulator which is responsible for converting MediaModel to ImageData. Once you have ImageData populated, you can display the image on the front end by using the following.

 <c:set value="${ycommerce:productImage(product, <media format to display>)}" var="productImage"/>
 
 <img src="${productImage.url}" alt="${fn:escapeXml(product.name)}" title="${fn:escapeXml(product.name)}" />


ycommerce:productImage calls getPrimaryImageForProductAndFormat in de.hybris.platform.acceleratorstorefrontcommons.tags.Functions class