When designing my Content Page Template, I added borders, backgrounds, and box shadows to style the images. However, if the optional image field is left empty, it still displays a small box with the css styling. I have been trying to figure out how to hide the entire .content-img class when there is no image present. The code provided below successfully renders the images if they are included. How can I modify it to hide the section if no image is present?
<?php the_field('top_headline'); ?></h1>
<div class="content-top"><?php the_field('content_top'); ?></div>
<div class="content-img"><?php
$image = get_field('content_image');
$size = 'medium'; // (thumbnail, medium, large, full or custom size)
if( $image ) {
echo wp_get_attachment_image( $image, $size );
} ?>
Any assistance on this issue would be greatly appreciated.