Skip to content

Instantly share code, notes, and snippets.

@mattboon
Created June 14, 2012 08:58
Show Gist options
  • Save mattboon/2929172 to your computer and use it in GitHub Desktop.
Save mattboon/2929172 to your computer and use it in GitHub Desktop.
WordPress - Remove inline <img> sizes / attributes
<?php
// Remove <img> dimensions
// -------------------------------------------------------------
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;
}
// Remove <br /> from [gallery] output
// -------------------------------------------------------------
add_filter( 'the_content', 'remove_br_gallery', 11, 2);
function remove_br_gallery($output) {
return preg_replace('/\<br[^\>]*\>/', '', $output);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment