Meow Apps

Media File Renamer: FAQ

Navigation Close

If your images or links are broken, there is a special page only about this here: Updating References & Links.

General Issues

You can keep the ALT text updated depending on the Title by checking the right option in the settings of the plugin. You can also customize it further by using the filter described below. Please note that the ALT text is updated in the Metadata of the Media entry. The HTML is not modified by the plugin.
I recommend you the excellent Redirection plugin. And to make your life easier, the Media File Renamer has a little feature. Visit Media > Renamer, and in the Before / After section click on Display Filenames, and once done, on Export as CSV. You can use import this CSV file directly into the Redirection plugin.
You need to have the Pro version activated. Also, in your settings (Meow Apps > Renamer), you need to have Manual Renaming enabled.
Did you migrate your files from one server to another? This might have created an encoding issue between your files (DB and file path has a different encoding). A user found a solution to this issue, here.
Let’s say you modify the titles of your media while editing a post. The plugin cannot rename the files yet, because you are in the process of editing your post and the image links are in there. If that option is checked, when the post is actually saved (drafted, scheduled or published), then the images will be renamed and the links updated. If you don’t check this option, you would have to go to the Media Manager and click on the button “Rename Now” next to that image.

Customization

Customize the filenames

We are all using different languages and our websites have different topics. Therefore, there are unlimited ways of automatically renaming filenames. Media File Renamer does it simply depending on the title you gave you the media. If you want to customize it, the best way is to implement this customization. You might need to be a developer to do this. The code below, for instance, will add “renamed-” in front of the filename proposed by the plugin. The $old filename is still accessible, and there is a reference to the attachment through the $post variable.

add_filter( 'mfrh_new_filename', 'my_filter_filename', 10, 3 );

function my_filter_filename( $new, $old, $post ) {
  return "renamed-" . $new;
}

Here is a more complex example, but also more interesting and useful. This one adds the upload date in front of the filename.

// Override the filename naming rules with this filter
add_filter( 'mfrh_new_filename', 'my_filter_filename', 10, 3 );

function my_filter_filename( $new, $old, $post ) {
  
  // Get the date from the $post (which is the media entry) and convert it to a timestamp
  $post_date = strtotime( $post['post_date'] );
  
  // Make this timestamp to looks like 2018-01-01
  $formatted_date = date('Y-m-d', $post_date);
  
  // Add this timestamp in front of the filename already decided by Media File Renamer
  $new_filename = $formatted_date . "-" . $new;
  
  return $new_filename;
}

Another filter allows you to do specify rules at the character level (but you can also specify whole strings).

add_filter( 'mfrh_replace_rules', 'replace_s_by_z', 10, 1 );

function replace_s_by_z( $rules ) {
  $rules['s'] = 'z';
  return $rules;
}

Generally, this code is added in the functions.php of your theme. You could also use a plugin such as Code Snippets.

Customize the ALT texts

You should use the mfrh_rewrite_alt filter.

add_filter( 'mfrh_rewrite_alt', 'my_alt_filter', 10, 3 ); 

function my_alt_filter( $alt ) {
return $alt . ' ' . get_bloginfo( 'name' );
}

Automation

Trigger the renaming process

If you are using plugins or tools which generate the posts and/or upload the images automatically for you, then Media File Renamer might not be able to rename those files as they are not considered new uploads. You will need to find out how to hook into that process, and then trigger the Media File Renamer manually.

Best is to ask the developer of the plugin you are using to automate your WordPress for the best way how to do it. Once you know where to hook, you simply need to call this function available globally: mfrh_rename( $mediaId ). Media File Renamer will rename this media entry depending on your settings.

Debug Issues

I am actively working on this page based on users’ request, issues, and questions. I am sorry if it seems a bit messy; I will make it clearer and better.

There are many themes and plugins available. Some of them manage images their own way, create their own metadata, hide important information in your database. Of course, Media File Renamer detects most of it and works perfectly on standard installs, but it can’t cover 100% of the WordPress installs, especially if they are a bit… exotic :) In those cases, the reference to the file might not be renamed and appear broken.

Timeouts, Big Installs, Slow servers

If you have a big install and/or a slow server, then you might experience timeouts. The plugin runs 2 to 4 queries on your database. Those queries replace the old filenames by the new filenames.

Here are a few workarounds:

  • Disable Updating References in the plugin’s options (if you don’t need those updates)
  • Increase the time before it timeouts (Increase limits)
  • Optimize the SQL queries specifically for your install (that should be done by a good developer around you); have a look at the action_update_posts and action_update_postmeta functions in the plugin
  • Any other idea? Please let a comment :)

I have been thinking of an alternative that could work: making the renaming asynchronous and renaming the files in the posts, parsing them one by one. Of course, that would be a bad alternative for those with no such issues as the plugin would become slower. Unfortunately, there are no other alternatives. I don’t think it’s an issue in the long run, installs are getting better, and hosting services faster.

Have you moved your WordPress to a new hosting service?

This is a really annoying issue as it is very technical, and difficult to resolve. It also impacts your WordPress install dramatically, even though… at first, everything seems to work perfectly.

Impacted WordPress installs are the ones using a lot of UTF-8 files. It means they contain a lot of non-ASCII characters, such as commas, quotes, accents, special characters, etc. Many of my clients had issues related to that.

How to resolve it? It’s best to ask your hosting service. But here is a quick idea for you: remove all the content of your /uploads folder, and re-upload the content of this folder from your previous hosting service by FTP using an option that enforces the usage of UTF-8.

My install is broken; how to debug?

  • Take a screenshot and share the link to the page where the image is used on your website.
  • Take a screenshot of the page where the image is used in your WordPress admin (we need to see the logical/technical link between what we see on the website and where the image is being set-up in the admin). For example, that image could be used in a simple post, so I need to see that image used in the post editor.
  •  In the case the image is used in one post, please share the HTML where the link to this photo appears.
  • From what to what did you rename that image? Using which settings?
  • You can enable the log in the File Renamer settings and try to rename that image to something else. Have a look at those logs, there might be something interesting in it.
  • Last but not least, check your PHP error logs. Maybe an error happens and that breaks the renaming process.

Maybe it is not broken: The Cache Issue

WordPress installs are very cached nowadays. By plugins, by hosting services, CDN, etc. After renaming your files, you need to clear your cache. Not only your browser cache, but also your hosting service’s cache. And if you are using plugins to make your website faster, they will also have an option to reset your cache.

Sometimes the cache is cleared automatically, and you might know that. But for example, a plugin like WP Rocket (that does cache) doesn’t react when the meta for a post is updated, it does only clear its cache when the post itself is updated. So this is important: don’t believe the caching plugins are perfect, and clear your cache regularly.

Repair your WordPress

If there is no backup, then there are two things you can try:

  • Un-Rename those files (= undo). There is an Undo option in the Advanced Settings of the plugin. Enable it and visit your Media Library. In the Rename column, you will notice a red arrow to come back, to undo. Click on it. You can bulk Undo in the Renamer dashboard.
  • Install the Regenerate Thumbnails plugin and run it on those images (or all your images).

Or else…

If you have a developer working for you, then he/she will be able to understand how your install work, and to teach Media File Renamer how to update the references, the way they are used by your install.

You can use the mfrh_url_renamed action (if you want to handle the new URL for this filename) or the mfrh_media_renamed action (if you want to handle the filename on your server) actions. Have a look at the examples in the plugins/custom.php file in the plugin directory.