DEV Community

Cover image for Replacing IMG alt values with title in js
Printing Digital
Printing Digital

Posted on

Replacing IMG alt values with title in js

We recently wanted to clean up some existing Wordpress sites for SEO, and part of that process involved fixing missing or broken IMG tags.

Here's a quick fix jquery solution for Wordpress you can use to replace IMG titles with the alt tag automatically. This way all your images without alt tags will be populated.

    jQuery("img").attr("title", function() {
         var theValue =  jQuery(this).attr("alt");
         return theValue;

In action at
Printing New York
Luxury Printing
Gorilla Printing
Printing Brooklyn

Top comments (0)