Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The widget() function for our Image of the Month Widget
<?php
function widget( $args, $instance )
{
extract($args);
$headline = $instance['headline'];
$image_id = $instance[$this->image_field];
$blurb = $instance['blurb'];
$image = new WidgetImageField( $this, $image_id );
echo $before_widget;
?>
<?php if( !empty( $headline ) ) : ?>
<h5 class="branded"><?php echo $headline; ?></h5>
<?php endif; ?>
<?php if( !empty( $image_id ) ) : ?>
<img src="<?php echo $image->get_image_src( 'thumbnail' ); ?>" width="<?php echo $image->get_image_width( 'thumbnail' ); ?>" height="<?php echo $image->get_image_height( 'thumbnail' ); ?>" />
<?php endif; ?>
<?php if( !empty( $blurb ) ) : ?>
<p><?php echo $blurb; ?></p>
<?php endif; ?>
<?php
echo $after_widget;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment