Skip to content

Instantly share code, notes, and snippets.

@dospuntocero
Created October 18, 2019 20:25
Show Gist options
  • Save dospuntocero/ba7b55c7437f963b63ceb4d27b95c5d9 to your computer and use it in GitHub Desktop.
Save dospuntocero/ba7b55c7437f963b63ceb4d27b95c5d9 to your computer and use it in GitHub Desktop.
remove width and height from wordpress images
add_filter( 'post_thumbnail_html', 'remove_wps_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_wps_width_attribute', 10 );
function remove_wps_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