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 from the Bulk Updater Settings tab of 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

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

Using Custom Filters For New Uploads

You can use the exact same filters for any new upload to the website. The Filter Settings for new uploads is split between Basic tab and Advanced tab of Image Attributes Pro. Every setting you used in Bulk Updater Settings is available there as well.

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.