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 all 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 @@ -24,6 +24,7 @@ though this project doesn't succeed in adhering to [Semantic Versioning](https:/
- Fixes an issue where the widget title wasn't displaying in the Largo Image Widget, due to trying to use the `$title` variable which was removed when we stopped using `extract` in [pull request #1565](https://github.com/INN/largo/pull/1565/). [Pull request #]() for [issue #1717](https://github.com/INN/largo/issues/1717).
- Added support for `wp_body_open` hook below opening body tag. [Pull request #1735](https://github.com/INN/largo/pull/1735) for [issue #1698](https://github.com/INN/largo/issues/1698).
- Added `font-display: block` to `fontello` font family. [Pull request #1742](https://github.com/INN/largo/pull/1742) for [issue #1686](https://github.com/INN/largo/issues/1686).
- 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
5 changes: 1 addition & 4 deletions css/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/style.min.css

Large diffs are not rendered by default.

33 changes: 22 additions & 11 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 @@ -119,17 +122,25 @@ function form( $instance ) {
</p>

<p><input id="<?php echo $this->get_field_id('show_byline'); ?>" name="<?php echo $this->get_field_name('show_byline'); ?>" type="checkbox" value="1" <?php checked( $instance['show_byline'], 1);?> />
<label for="<?php echo $this->get_field_id('show_byline'); ?>"><?php _e( 'Show date on first post', 'largo' ); ?></label>
<label for="<?php echo $this->get_field_id('show_byline'); ?>"><?php _e( 'Show byline on first post?', 'largo' ); ?></label>
</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
3 changes: 0 additions & 3 deletions less/inc/widgets/largo-series-posts.less
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
margin-left: 0;
list-style: none;
}
img {
max-width: 100px;
}
i {
display: block;
float: left;
Expand Down