Conditional statement in image.php
-
I should welcome a bit of help with an edit to my image.php file…
I am using the inbuilt WordPress Gallery and when a visitor clicks a thumbnail in the blog it opens the corresponding large image.
My aim is to have the image description in a grey box (using class wp-caption from the CSS) below some of the images. At the moment, I acheive this using the following bit of code within image.php:
<?php echo wp_get_attachment_image( $post->ID, 'large' ); ?> <div class="wp-caption"><?php if ( !empty($post->post_content) ) the_content(); ?></div>
However with this code, if I don’t wish to enter a description for a particular image, an empty thin grey box will show under the full size image.
How should I alter the code so as to prevent the box from appearing if the image hasn’t been given a description?
I can provide a link to the blog if required. Thanks in advance.
- The topic ‘Conditional statement in image.php’ is closed to new replies.