Skip to content

Instantly share code, notes, and snippets.

@PittsburghChris
Created May 5, 2014 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PittsburghChris/32dfc5abdb51e0ef7414 to your computer and use it in GitHub Desktop.
Save PittsburghChris/32dfc5abdb51e0ef7414 to your computer and use it in GitHub Desktop.
Wrap images with figure tag
// Wrap images with figure tag. Courtesy of Interconnectit http://interconnectit.com/2175/how-to-remove-p-tags-from-images-in-wordpress/
if( ! function_exists( 'reverie_img_unautop ' ) ) {
function reverie_img_unautop($pee) {
$pee = preg_replace('/<p>\\s*?(<a .*?><img.*?><\\/a>|<img.*?>)?\\s*<\\/p>/s', '<figure>$1</figure>', $pee);
return $pee;
} /* end reverie_img_unautop */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment