Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dirkeinecke/4c6c05abf8b1e50181fbcb89388e2e6e to your computer and use it in GitHub Desktop.
Save dirkeinecke/4c6c05abf8b1e50181fbcb89388e2e6e to your computer and use it in GitHub Desktop.
WordPress – remove “height” and “width” attributes of images
add_filter('post_thumbnail_html', 'remove_thumbnail_dimensions', 10);
add_filter('image_send_to_editor', 'remove_thumbnail_dimensions', 10);
add_filter('the_content', 'remove_thumbnail_dimensions', 10);
function remove_thumbnail_dimensions($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