mardi 31 mars 2015

Trying to hide image styling, if no image is present - Advanced Custom Fields images

I have styled my images on my Content Page Template to have borders, backgrounds and box-shadow. If I don't use the optional image field and leave it empty, it leaves the css styling with a small box. I have been trying to hide the entire .content-img class if there is no image present. The code below works fine for rendering the images if they are present. How to hide it 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 ); } ?>


Thanks for your help in advance.


Aucun commentaire:

Enregistrer un commentaire