Skip to content

Instantly share code, notes, and snippets.

@Boztown
Created September 9, 2013 01:29
Show Gist options
  • Save Boztown/6490330 to your computer and use it in GitHub Desktop.
Save Boztown/6490330 to your computer and use it in GitHub Desktop.
Remove hard-coded width/height from image thumbnails in Wordpress.
// remove hard-coded width/height
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10, 3 );
function remove_thumbnail_dimensions( $html, $post_id, $post_image_id ) {
$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