wordpress snippets last updated   : July 14, 2014
we now have 634 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


jqsnipp.com | we just launched jquery snippets website