Title: Conditional statement in image.php
Last modified: August 19, 2016

---

# Conditional statement in image.php

 *  Resolved [jtonline](https://wordpress.org/support/users/jtonline/)
 * (@jtonline)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/conditional-statement-in-imagephp/)
 * 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.

Viewing 1 replies (of 1 total)

 *  Thread Starter [jtonline](https://wordpress.org/support/users/jtonline/)
 * (@jtonline)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/conditional-statement-in-imagephp/#post-900172)
 * Never mind. I surrounded the whole image & descripton with the class which looks
   better and overcomes the problem.

Viewing 1 replies (of 1 total)

The topic ‘Conditional statement in image.php’ is closed to new replies.

 * 1 reply
 * 1 participant
 * Last reply from: [jtonline](https://wordpress.org/support/users/jtonline/)
 * Last activity: [17 years, 7 months ago](https://wordpress.org/support/topic/conditional-statement-in-imagephp/#post-900172)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
