Filter Custom Characters With Custom Filter And Regex Filter

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:

Filter Settings Regex Filter In 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: businessname-words-to-desribe-the-image-sequencenumber-ratio-dimensions-quality.jpg

An example of that would be: abcphotography-lion-walking-towards-sunset-01-16x9-2880x1620px-10pct.jpg

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 filename in Filter Settings
  • There is a filter setting to remove numbers. However since all images have a pattern, it’s better to use the regex filter.
  • Add /(\d+x)|(\d+px)|(\d+pct)|(\d+)/ to the regex filter. (I tested it with the help of regex101.com)
  • Select the appropriate Capitalization Settings as you see fit.

This is what the settings will look like:

Custom Filter And Regex Filter Image Attributes Pro

You can see the end result below:

Custom Filter And Regex Filter Image Attributes Pro Result

Example Usage 2

Another common format for images is to have the dimension attached to the filename. For example, microsoft-xbox-768x430.jpg

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.

Was this article helpful?
Yes, thanks! 👍Not really 👎