WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does anyone know how I could change the way wordpress saves the featured image's additional image sizes?

Right now I have the main image saving like so:


and for each additional image size it saves like so:


All I want to do is get rid of the "-" between the name of the file and the file size, and replace it with an underscore.

Is there a filter I can use or something of that sort?

share|improve this question

There is a filter to use for the array containing the filename that is saved to postmeta but since there are no filters available to change the filename before it is saved you have to manually change it using rename().

function wpse_filter_image_resize_name( $filename ) {
    $new_name = preg_replace( "/-(?<match>\\d)/ui", "_$1", $filename );

    if ( rename( $filename, $new_name ) )
        return $new_name;

    return $filename;
add_filter( 'image_make_intermediate_size', 'wpse_filter_image_resize_name' );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.