WP Smush: Clean accent characters from image file names

It might be useful to include a feature in Smush to clean up image filenames removing accent characters (á, é, í, ó, ú). I’ve just finished a WMPL site for a French client and some of her image filenames give a 404 error

  • Sajid
    • DEV MAN’s Sidekick

    Hi Oliver Partridge,

    Hope you are doing good today :slight_smile:

    That will be a good addition in Smush Plugin and will definitely help optimize images. Since its already in a feature request from where it can be considered for development.

    Meanwhile, I found a plugin that claims to remove the special characters from image file names.

    https://wordpress.org/plugins/clean-image-filenames/

    Take care and have a nice day :slight_smile:

    Kind Regards,

    Sajid

  • Oliver
    • Site Builder, Child of Zeus

    Thanks Sajid,

    I did try that specific plugin and I couldn’t see how it would work for images already in the library. I think it only works on images that are uploaded once the plugin is activated.

    I think there is a function in WP Core that sanitizes filenames already? My French client had her install from WP v3.6.1, so this function may not have been there at that time, hence she had a fair few images that still had accent characters in the filenames.

  • Sajid
    • DEV MAN’s Sidekick

    Hi Oliver Partridge,

    Hope you are doing good today :slight_smile:

    Yes, there is indeed a function to sanitize the file name of WordPress media images. Here are more information about the this function on WordPress developer docs.

    But according to docs, its been there since WordPress 2.1.0.

    Regarding the plugin, I can see that it uses sanitize_title instead of sanitize_file_name. But yeah, it does sanitize file names while uploading the files and no bulk or existing images option is there.

    Take care and have a nice day :slight_smile:

    Kind Regards,

    Sajid

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.