Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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();

?>
share|improve this question
    
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 '12 at 6:20
    
see the test code to see how I am adding the new image size. –  Mike Jan 24 '12 at 17:16
    
Ahh, found it. Looks like a bug. Will report upstream. –  Otto Jan 24 '12 at 19:32
    
Reported: core.trac.wordpress.org/ticket/19889 –  Otto Jan 24 '12 at 19:49

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
    
glad to see this is on the path to being fixed. Nice work. –  Mike Jan 25 '12 at 3:22

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.

share|improve this answer

Your Answer

 
discard

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.