Skip to content

Commit

Permalink
Wrap an img in a .thumbnail element if caption is present
Browse files Browse the repository at this point in the history
  • Loading branch information
jgrossi committed Aug 17, 2016
1 parent bdf6282 commit 50931e0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions widgets/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ public function widget( $args, $instance ) {
$caption = isset( $instance['caption'] ) ? trim($instance['caption']) : '';
$url = isset( $instance['url'] ) ? $instance['url'] : '';
echo $args['before_widget'];
?>
<img src="<?php echo $url; ?>" class="<?php echo $classes; ?>" alt="<?php echo $alt; ?>" />
<?php if ( $caption ): ?>
<p class="help-block"><small><?php echo $caption; ?></small></p>
if ($caption): ?>
<div class="thumbnail">
<img src="<?php echo $url; ?>" alt="<?php echo $alt; ?>" class="<?php echo $classes; ?>">
<div class="caption"><?php echo $caption; ?></div>
</div>
<?php else: ?>
<img src="<?php echo $url; ?>" class="<?php echo $classes; ?>" alt="<?php echo $alt; ?>" />
<?php endif;
echo $args['after_widget'];
}
Expand Down

0 comments on commit 50931e0

Please sign in to comment.