In the category page I would like to show its corresponding alt for each product image, but by default my theme Claue show the product name in the alt label.

In the phtml file /design/frontend/Mgs/claue/Magento_Catalog/templates/product/list.phtml

stripTags($_product->getImageLabel(), null, true); ?>

The problem is that for some images it shows the alternative text and for others it does not and show the alt="".

Somebody could help me?


Its using the image label and not the product name. Change your snippet to :

stripTags($_product->getName(), null, true); 
| improve this answer | |
  • Yes, I want to use the label name and not the product name. The problem is that although the product has a label name on the category page, some product is not shown while on the product page if it is displayed correctly. From my point of view it does not make sense for the same image to have different alts one on the category page and another on the products page and for this reason I want to show the alt of the image always and not the name of the product. – Juan Dosil Feb 20 '19 at 11:21

Your Answer

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

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