Removing Images in a WordPress Post (Revisited)

- 23 Apr 2009

A while back I wrote a semi-popular post on removing images from a WordPress post – today I am revisiting it. The original solution used the_content() and the output buffer to remove the images out of the post. Now that I have used WordPress a bit longer and candidly had to use the solution again and thought ”what was I thinking” I thought I would share the cleaner solution:

<?php echo preg_replace('/&lt;img[^&gt;]+./','',get_the_content()); ?>

Related Posts: Extracting Smarty variables from source » Installing vzdump on CentOS 5.4 (32-bit) » Dumping Addresses from phplist » Adding NRPE (Nagios) to CentOS \/ RHEL Servers » Adding the REMI Repository to CentOS / RHEL / RedHat »

comments powered by Disqus