WordPress.org

Ready to get started?Download WordPress

Forums

Change filename/naming convention of file on upload (2 posts)

  1. kaffolder
    Member
    Posted 1 year ago #

    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-640x480.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-640x480.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?

  2. bsieders
    Member
    Posted 1 year ago #

    Hi Kaffolder,

    I was looking for the same thing and found the solution here:

    http://wordpress.stackexchange.com/questions/82193/rename-image-uploads-with-width-in-filename

    Cheers

Topic Closed

This topic has been closed to new replies.

About this Topic