<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>bavotasan.com &#187; the_content()</title>
	<atom:link href="http://bavotasan.com/tag/the_content/feed/" rel="self" type="application/rss+xml" />
	<link>http://bavotasan.com</link>
	<description>by c.bavota</description>
	<lastBuildDate>Tue, 07 Feb 2012 15:42:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>A Better Way to Remove Images from a WordPress Post</title>
		<link>http://bavotasan.com/2011/a-better-way-to-remove-images-from-a-wordpress-post/</link>
		<comments>http://bavotasan.com/2011/a-better-way-to-remove-images-from-a-wordpress-post/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 16:08:25 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[remove images]]></category>
		<category><![CDATA[strip images]]></category>
		<category><![CDATA[the_content()]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=3551</guid>
		<description><![CDATA[I had originally written about Removing Images from a WordPress Post quite a while ago, and while that snippet still works, I recently discovered another way to do it that might help some people. This way hooks into the content filter. &#60;?php function remove_images&#40; $content &#41; &#123; $postOutput = preg_replace&#40;'/&#60;img[^&#62;]+./','', $content&#41;; return $postOutput; &#125; add_filter&#40; [...]]]></description>
			<content:encoded><![CDATA[<p>I had originally written about <a href="http://bavotasan.com/tutorials/removing-images-from-a-wordpress-post/">Removing Images from a WordPress Post</a> quite a while ago, and while that snippet still works, I recently discovered another way to do it that might help some people. This way hooks into the content filter.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> remove_images<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$content</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$postOutput</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/&lt;img[^&gt;]+./'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">return</span> <span style="color: #000088;">$postOutput</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'remove_images'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

<p>If you include this in your functions.php it will remove every image from the content everywhere <code>the_content()</code> function has been used. That isn&#8217;t probably what you want, but what you can do is include this function in a specific page template, such as your index.php file, and then at the end of that file include the following to remove the filter:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> remove_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'remove_images'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2011/a-better-way-to-remove-images-from-a-wordpress-post/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

