Skip to content

Instantly share code, notes, and snippets.

@davidvandenbor
Last active November 4, 2015 10:03
Show Gist options
  • Select an option

  • Save davidvandenbor/9e41a63ba9ff37336038 to your computer and use it in GitHub Desktop.

Select an option

Save davidvandenbor/9e41a63ba9ff37336038 to your computer and use it in GitHub Desktop.
WordPress: remove width and height attributes from imh html
<?php
add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 );
function remove_width_attribute( $html ) {
$html = preg_replace( '/(width|height)="\d*"\s/', "", $html );
return $html;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment