Created
June 1, 2012 14:37
-
-
Save bgallagh3r/2852576 to your computer and use it in GitHub Desktop.
Wordpress: Filter to remove image dimension attributes (width and height)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function remove_thumbnail_dimensions( $html ) { | |
$html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html ); | |
return $html; | |
} | |
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 ); | |
add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 ); | |
// Removes attached image sizes as well | |
add_filter( 'the_content', 'remove_thumbnail_dimensions', 10 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment