Viewing 5 replies - 1 through 5 (of 5 total)
  • Depends on where you want to remove the tag from. If it’s the content of the posts then use the the_content filter and a preg_replace or whatever.

    ~ @kovshenin

    Thread Starter downfast

    (@downfast)

    i am trying to use this within the loop <?php remove_filter('the_content', '<img>');?> but it doens’t work, am i doing something wrong?

    Of course, read more about what filter are and how to use them. You should be doing something similar to this:

    add_filter('the_content', 'my_content_filter');
    function my_content_filter($content)
    {
        $content = preg_replace('#(<[/]?img.*>)#U', '', $content);
        return $content;
    }

    Haven’t tested this regex but it’s the first one I found in Google using ‘preg_replace img tag’. Anyways, you should be able to get the picture.

    ~ @kovshenin

    Thread Starter downfast

    (@downfast)

    superb it works 🙂 thank you

    Hi Kovshenin,

    Is it possible to do the opposite? So remove all data from The_Content except the IMG??? This way I can get only my images posted on my blog.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘how to write a filter to remove img tag?’ is closed to new replies.