Removing the paragraph tag from images in wordpress

Sort of annoying – wordpress and the <p> tags.  To remove them from automatically surrounding your images, put this in your functions.php file.  Thanks to css-tricks.com.
function filter_ptags_on_images($content){
return preg_replace('/<p>s*(<a .*>)?s*(<img .* />)s*(</a>)?s*</p>/iU', '123', $content);
}

add_filter(‘the_content’, ‘filter_ptags_on_images’);

 

June 26th, 2013|blogging services, WordPress|