php – Add/alter image attribute before render

Question

I have different images on each of my products pages, and I would like to programmatically, through PHP, add alt attributes to these images. The alt attribute value would be based on the title of the product. I could add the alt text manually through the media library, but there are hundreds of images, so that would be a last resort. I cannot do this through JavaScript because then web crawlers wouldn’t detect the alt text, which would be bad for SEO.

Basically what I’m looking for is some hook that gets called before echoing images, that would also allow me to alter the image attributes.

0
JorensM 2 months 2022-11-28T03:19:44-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse