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;

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

  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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