In one of project I got requirement of to exclude images from WordPress post.
I written following code for excluding the image from Post
Above line I added in showing post without image.
$FormatedContent = content_with_formatting();
$content = the_content();
$postWithoutImage = preg_replace(‘/<img[^>]+./’,” $FormatedContent);
In above code we are checking the image tag and replacing with none.
If you want to find all images from post then Use following command.
You need to add following function in your function.php file(Theme files).
function content_with_formatting($more_link_text = ‘(more…)’, $stripteaser = 0, $more_file = ”)
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters(‘the_content’, $content);
$content = str_replace(‘]]>’, ‘]]>’, $content);
If you want to Hide all images using CSS then use following code
Just put above code in your style.css file.