I have lots of images that has to be uploaded via media library. I want to know, is it possible to add file name to alt
attribute field automatically when I am uploading them? At the moment I have to open each image and add the alt
attribute manually.
2 comments
Comments are closed.
A viable solution I found was adding the post title to images missing the
ALT
attribute.Add the following to your
functions.php
file:Alternatively, if you want to replace the attribute with the file name, you could look into using the get_attached_file function for the
$new_img
variable.I know I am very late to the party, but I couldn’t let this one pass because I wrote a plugin just for this: Auto Image Attributes From Filename With Bulk Updater
As the name suggests, there is a bulk updater as well, so you can update existing images as well.