Remove images from post content on your WordPress homepage

Worried that all the images in your posts on your home page are slowing your page speed down? Or just want to de-clutter things? Or perhaps you need to cut down on bandwidth and want to reduce the page size on your most visited page (your homepage).

WordPress snippet to remove images from your homepage posts

function tcb_remove_images_from_homepage( $content ) {
   if( is_home() )
     $content = preg_replace('/<img[^>]+./','', $content);
   return $content;
add_filter( 'the_content', 'tcb_remove_images_from_homepage', 100 );

Personally, I’d just get some better hosting and not worry about it 🙂