Image Attributes Pro already comes with a range of common special characters that you can remove from the image filename to generate image attributes like alt text and image title.
Here is a screenshot of the available
Filter Settings Image Attributes Pro:
Right below the available filters you have the
Custom Filter and in this doc we will see how to use them to generate the attributes that we want.
Custom Filter And Regex Filter
The custom filter can be used to filter out any characters or words. Words or characters can be comma separated and are case sensitive.
Advanced users can use the regular expression (regex) part of the custom filter to filter out patterns from the image filename before it’s used as an image attribute.
Example Usage 1
Let’s say you are a photographer and all your images are named in this format:
An example of that would be:
You want to generate the image attribute as:
Lion Walking Towards Sunset
Here are the settings to select in the
Bulk Updater Settings tab.
- To remove the hyphens select
Remove hyphens ( - ) from filenamein
- There is a filter setting to remove numbers. However since all images have a pattern, it’s better to use the
regex filter. (I tested it with the help of regex101.com)
- Select the appropriate
Capitalization Settingsas you see fit.
This is what the settings will look like:
You can see the end result below:
Example Usage 2
Another common format for images is to have the dimension attached to the filename. For example,
To remove the dimension alone (i.e.
768x430 in our example), use this in the regex filter:
/(\d+x)|(\d+)/. Here is the same in regex101.com.
If you want even more customization, you can use the iaffpro_image_attributes WordPress filter to customize the attributes.
Always make a database backup before you begin and use the
Test Bulk Updater button to see if you like the results before you update the entire website.