How to remove text and retain in caption image using the_content function

If you are trying to remove the text i think the below code is what is adding this

/// this is where your content is being inserted
               <div class="strip_first_image">
    <?php $content = get_the_content();$content = preg_replace("/<img[^>]+\>/i", " ", $content); $content = preg_replace("/\[caption.*\[\/caption\]/", '', $content);$content = apply_filters('the_content', $content);$content = str_replace(']]>', ']]>', $content);echo $content;
    ?>
    </div>

Someone with better code skills might be able to correct me if I am wrong on the below

The get_the_content(); is bringing in your content from the post and it seems to be stripping out the images using preg_replace("/<img[^>]+\>/i", " ", $content);

Then $content = preg_replace("/\[caption.*\[\/caption\]/", '', $content); is removing the captions

After this it is calling a custom hook created and using apply_filters to run this on the content but I don’t know what this would be doing.

I hope the above helps you to try remove the text if that was your aim as your title is not enough to go on what you actually are requesting.

Edit for the comment.

Try to add /* */ to that section and see if it only removes the text.

<?php /* $content = get_the_content();$content = preg_replace("/<img[^>]+\>/i", " ", $content); $content = preg_replace("/\[caption.*\[\/caption\]/", '', $content);$content = apply_filters('the_content', $content);$content = str_replace(']]>', ']]>', $content);echo $content;
    */?>