ThemeShaper Forums » Thematic


Removing images from within post content

(2 posts)
  • Started 10 years ago by tarpontech
  • Latest reply from tarpontech
  • This topic is resolved
  1. I'd like for all pages displaying posts to show the full text of the post, but have images stripped out.

    preg_replace('/<img[^>]+./','' appears to be the right filter, but I cannot seem to
    figure out how to apply this to a thematic filter of the_content.

    function my_content() {
    		if ( is_home () ) {
    		    $mypost= preg_replace('/<img[^>]+./','',$post);
    			$mypost = get_the_content(more_text());
    			$mypost = str_replace(']]>', ']]>', $post);
    			$post = $mypost;
    		return $post;
    	add_filter('thematic_content' , 'my_content');

    I just tossed that out here....I know i'm probably not applying this correctly. I don't necessarily need someone to write the code for me, perhaps just direct me to the php or wordpress function I need to grasp better to be able to utilize this.

    Posted 10 years ago #
  2. BAM!

    //remove images from content
    function rip_img($content) {
    $content = preg_replace("~<img (.*?)>~","","$content");
    	return $content;
    add_filter( 'the_content', 'rip_img' );
    Posted 10 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.