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.

I can't seem to find the filter for an image update.

Right now I have the code below, which works great until someone clicks on an image in the editor and updates it. Then it throws the height and width back in. Is there a filter I can use to stop this? I've tried several to no avail.

add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );

function remove_thumbnail_dimensions( $html ) {
    $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
    return $html;
}
share|improve this question

1 Answer 1

You'll have to abort depending on the $_REQUEST['action'], $_POST['action'] or $_GET['action'].

share|improve this answer
    
I'm not sure how this would work? Is there not a filter for the image update box? –  Ian Hoar Aug 24 '12 at 20:29
    
Inspect your URl and the ajax requests you're doing. You'll see something like ?action=resize for example. Then check if ( isset( $_REQUEST['action'] ) && 'resize' === $_REQUEST['action'] ) return $html before you do the preg_replace. –  kaiser Aug 25 '12 at 7:53

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.