Hello Magento Friends,

Today I will be explaining How to Set Product Name as Default Alt Text to All Product Images in Magento 2.

Alt text for product images informs the search engine what the image is about and helps index the product image when the user fires a query related to it. For Magento 2 stores, it is essential to give alt text to all the product images to aid in search engine rankings. Large stores can take advantage of Magento 2 Image Alt Tags Extension to automate the product image alternate text process and save time.

You can also set the product name as the default alt text for all the product images in Magento 2. To do that, follow the below-given steps

Steps to Set Product Name as Default Alt Text to All Product Images in Magento 2:

Step 1: First, we need to create a “di.xml” file inside our extension at the following path

app\code\Vendor\Extension\etc\frontend

Then add the code as follows

Step 2: After that, we need to create a “ Plugin .php” file inside extension Controller directory

app\code\Vendor\Extension\Block\Product\View\Gallery\

Now add the code as mentioned below

Conclusion:

This way you can easily Set Product Name as Default Alt Text to All Product Images in Magento 2. If you have any doubts about the above steps, freely share with me via the comment part. I will definitely solve your problem. Share the tutorial with your friends and stay in touch for more solutions.

Also, check Magento 2 WebP Image Converter Extension to automatically convert your image to webp image.

Happy Coding!

Click to rate this post!
[Total: 6 Average: 5]