1

When rotating an image with the WordPress image editor it creates new images and renames all of the images for the thumbnail, medium and large image sizes that are default for WordPress.

My problem is that I have registered new image sizes using add_image_size();

Is there anyway to make WordPress rename/rotate these custom image sizes?

If there is a way to just have it replace the original image names that would be great. So we don't end up with strange image names like My_Image-e13232345234234-200x600.jpg.

EDIT

Below is a test plugin that shows this happening. Paste the code in a file in your plugins folder, then upload an image such as my_image.jpg. You should now have my_image-30xY.jpg. Now if your rotate the image you will get only 4 new images such as my_image-e1343232354234.jpg, but there will not be a new image for the "test" image size.

<?php

/*
Plugin Name: Test
Description: this is a test
Author: Mike
Version: .1
*/

class test{

    function __construct(){
    add_action( 'after_setup_theme', array($this, 'add_image_sizes') );
    }

    function add_image_sizes(){
    add_image_size( 'test', '30', '30' );
    }
}

new test();

?>
4
  • The image rotation code in the core calls the get_intermediate_image_sizes function to determine which sizes to rotate. This will return all available sizes, including custom ones. So rotation should apply to them too as long as you are selecting to apply the rotation to all sizes. Are you adding your sizes correctly in your theme/plugin code? What hook are you attaching the code to?
    – Otto
    Jan 24, 2012 at 6:20
  • see the test code to see how I am adding the new image size.
    – Mike
    Jan 24, 2012 at 17:16
  • Ahh, found it. Looks like a bug. Will report upstream.
    – Otto
    Jan 24, 2012 at 19:32
  • Reported: core.trac.wordpress.org/ticket/19889
    – Otto
    Jan 24, 2012 at 19:49

2 Answers 2

1

From examination, it looks like a bug. I can't think of a good reason it shouldn't apply those changes.

Reported: http://core.trac.wordpress.org/ticket/19889

Patch in that ticket fixes the problem.

Also, in response to your other question, you can define IMAGE_EDIT_OVERWRITE to true in the wp-config file to make it not create those oddly named files and to just overwrite the original names. This will break the "restore image" capability of the built in editor though.

2
  • glad to see this is on the path to being fixed. Nice work.
    – Mike
    Jan 25, 2012 at 3:22
  • FYI: IMAGE_EDIT_OVERWRITE does not break restore capability at the moment. Maybe it did when this was written 3 years ago, but not anymore.
    – bradt
    Feb 22, 2015 at 19:31
0

the patch is no longer working, since the edit-image.php file changed. this worked for me (wp 3.8.1). no wp core hacking required. yay.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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