Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swapped out series post widget image location for image size + alignment options #1734

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ though this project doesn't succeed in adhering to [Semantic Versioning](https:/
- Fixes an undefined variable error in certain edge cases of the site `og:description` and `description` meta tags. [Pull request #1724](https://github.com/INN/largo/pull/1724) for [issue #1721](https://github.com/INN/largo/issues/1721).
- Co-Authors Plus profile field descriptions no longer contain escaped HTML. [Pull request #1726](https://github.com/INN/largo/pull/1726) for [issue #1720](https://github.com/INN/largo/issues/1720).
- Fixes multiple `Undefined variable: post` errors in `homepage/templates/top-stories.php`. [Pull request #1728](https://github.com/INN/largo/pull/1728) for [issue #1723](https://github.com/INN/largo/issues/1723).
- Replaced image settings in the Largo Series Posts widget to mirror the image settings in the Largo Recent Posts widget. [Pull request #1734](https://github.com/INN/largo/pull/1734) for [issue #1727](https://github.com/INN/largo/issues/1727).

## [Largo 0.6.3](https://github.com/INN/largo/compare/v0.6.2...v0.6.3)

Expand Down
31 changes: 21 additions & 10 deletions inc/widgets/largo-series-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function widget( $args, $instance ) {
$instance['title_link'] = get_term_link( (int) $instance['series'], 'series' );
$term = get_term( $instance['series'], 'series' );
$title = apply_filters( 'widget_title', $term->name, $instance, $this->id_base );
$thumb = isset( $instance['thumbnail_display'] ) ? $instance['thumbnail_display'] : 'small';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was it intended to change the default from medium -> small? Also, is it possible that thumbnail_display could have an unexpected size value and does this need to be handled?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to copy the functionality from one of our other widgets, so the small default is ok.

It will be a selected from a dropdown, so I doubt there would be an unexpected size value. @benlk Do you know if that's ever happened with the Largo Recent Posts widget that this was copied from?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it has ever happened.

The template that this widget renders only has cases for small, medium, and large, so an invalid choice or the none option would result in no thumbnail displaying:

https://github.com/INN/largo/blob/67b4dedb252220515243756e96ed2033dd7f0d38/partials/widget-content.php#L9-L30


echo $args['before_widget'];

Expand All @@ -38,7 +39,7 @@ function widget( $args, $instance ) {

$context = array(
'instance' => $instance,
'thumb' => 'medium',
'thumb' => $thumb,
'excerpt' => 'custom_excerpt'
);
largo_render_template('partials/widget', 'content', $context);
Expand Down Expand Up @@ -77,7 +78,8 @@ function update( $new_instance, $old_instance ) {
$instance['num'] = (int)$new_instance['num'];
$instance['series'] = sanitize_key( $new_instance['series'] );
$instance['show_byline'] = (int) $new_instance['show_byline'];
$instance['thumbnail_location'] = sanitize_key( $new_instance['thumbnail_location'] );
$instance['thumbnail_display'] = sanitize_key( $new_instance['thumbnail_display'] );
$instance['image_align'] = sanitize_key( $new_instance['image_align'] );
return $instance;
}

Expand All @@ -88,7 +90,8 @@ function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array(
'num' => 4,
'heading' => 'Explore:',
'thumbnail_location' => 'before',
'thumbnail_display' => 'small',
'image_align' => 'left',
'show_byline' => 0,
'series' => 'null')
);
Expand Down Expand Up @@ -123,13 +126,21 @@ function form( $instance ) {
</p>
benlk marked this conversation as resolved.
Show resolved Hide resolved

<p>
<label for="<?php echo $this->get_field_id('thumbnail_location'); ?>"><?php _e('Thumbnail position on first post', 'largo'); ?>:</label>
<select name="<?php echo $this->get_field_name('thumbnail_location'); ?>" id="<?php echo $this->get_field_id('thumbnail_location'); ?>">
<?php
$choices = array( 'before' => __( 'Before Headline', 'largo' ), 'after' => __( 'After Headline', 'largo' ) );
foreach( $choices as $i => $display ) {
echo '<option value="', $i, '"', selected($instance['thumbnail_location'], $i, false), '>', $display, '</option>';
} ?>
<label for="<?php echo $this->get_field_id( 'thumbnail_display' ); ?>"><?php _e( 'Thumbnail Image', 'largo' ); ?></label>
<select id="<?php echo $this->get_field_id( 'thumbnail_display' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail_display' ); ?>" class="widefat" style="width:90%;">
<option <?php selected( $instance['thumbnail_display'], 'small'); ?> value="small"><?php _e( 'Small (60x60)', 'largo' ); ?></option>
<option <?php selected( $instance['thumbnail_display'], 'medium'); ?> value="medium"><?php _e( 'Medium (140x140)', 'largo' ); ?></option>
<option <?php selected( $instance['thumbnail_display'], 'large'); ?> value="large"><?php _e( 'Large (Full width of the widget)', 'largo' ); ?></option>
<option <?php selected( $instance['thumbnail_display'], 'none'); ?> value="none"><?php _e( 'None', 'largo' ); ?></option>
</select>
</p>

<!-- Image alignment -->
<p>
<label for="<?php echo $this->get_field_id( 'image_align' ); ?>"><?php _e( 'Image Alignment', 'largo' ); ?></label>
<select id="<?php echo $this->get_field_id( 'image_align' ); ?>" name="<?php echo $this->get_field_name( 'image_align' ); ?>" class="widefat" style="width:90%;">
<option <?php selected( $instance['image_align'], 'left'); ?> value="left"><?php _e( 'Left align', 'largo' ); ?></option>
<option <?php selected( $instance['image_align'], 'right'); ?> value="right"><?php _e( 'Right align', 'largo' ); ?></option>
</select>
</p>

Expand Down