Skip to content

Instantly share code, notes, and snippets.

@jeremyboggs
Created November 23, 2010 13:44
Show Gist options
  • Save jeremyboggs/711775 to your computer and use it in GitHub Desktop.
Save jeremyboggs/711775 to your computer and use it in GitHub Desktop.
<?php
/**
* Removes inline width and height attributes for images. Thanks to
* @boonebgorges and @wayne_graham for help with this!
*/
function clioweb_remove_inline_sizes($html) {
$pattern = '/(\sheight|\swidth)="(.*?)"/';
$html = preg_replace($pattern, '', $html);
return $html;
}
add_filter( 'get_image_tag', 'clioweb_remove_inline_sizes', 10, 1 );
@waynegraham
Copy link

In case you didn't see the notice, I smashed the regex into a single check to avoid loop check https://gist.github.com/720074

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment