wordpress snippets last updated   : January 29, 2015
we now have 646 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 →

Did you like this post? If so please share it with your friends. Thanks!

  • Luke

    I love you man! great script

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