WordPress.org

Support

Support » Plugins and Hacks » Hacks » Change filename/naming convention of file on upload

Change filename/naming convention of file on upload

  • Is there a way to change the naming convention that WP uses on file uploads when it creates intermediate (scaled) sizes? For example, when I upload “test-photo.jpg”, it will output intemediate sizes with the following naming convention: test-photo-{scaled-width}x{scaled-height}.jpg. So, in context, the file might be named: “test-photo-640×480.jpg”.

    Is there a way to change this without hacking WP’s core so that instead images will be named with only the width attribute? ie. test-photo-640.jpg?

    Ideally, I’d still like to be able to use native WP functionality and not use an outside library such as TimThumb to create the resized versions.

    Would there be some type of regex work-around I could use that would read the characters from the ‘x’ to the ‘.’ of the extension and remove that? So, in my above example, it would remove the ‘x480’ from ‘test-photo-640×480.jpg’.

    Or, is there a better way to do this by hooking into a WP function and changing how it names intermediate sizes?

    Looks like maybe the functions on these lines 389 or 432 in wp-includes/media.php is where the intermediate sizes are named/created?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Change filename/naming convention of file on upload’ is closed to new replies.