wordpress snippets last updated   : April 22, 2014
we now have 631 snippets

Automatically wrap images in the_content with custom html

wordpress snippet

Adding this snippet to the functions.php of your wordpress theme will automatically wrap images in the_content with any custom HTML that you wish.

snippet :  PHPcopy
function filter_images($content){
    return preg_replace('/<img (.*) \/>\s*/iU', '<span class="className"><b><img \1 /></b></span>', $content);
}
add_filter('the_content', 'filter_images');
source →
  • Luke

    I love you man! great script

  • http://soffile.blogspot.com/ Danish Raza

    great!

jqsnipp.com | we just launched jquery snippets website