WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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


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.