Add quality param to showcase shortcode
Allows to change the image size from default 'medium'.
This commit is contained in:
parent
00197b5290
commit
a9d9e6a18f
@ -1360,6 +1360,7 @@ Renders dynamic grid of thumbnails with title, showing the latest eight posts of
|
|||||||
* **width:** Override the item minimum width (it will still be stretched to fill the space).
|
* **width:** Override the item minimum width (it will still be stretched to fill the space).
|
||||||
* **class:** Additional CSS classes, separated by whitespace.
|
* **class:** Additional CSS classes, separated by whitespace.
|
||||||
* **splide:** Configuration JSON to turn the grid into a slider. See [Slider](#slider).
|
* **splide:** Configuration JSON to turn the grid into a slider. See [Slider](#slider).
|
||||||
|
* **quality:** Either `'snippet'`, `'thumbnail'`, `'cover'`, `'medium'`, `'medium_large'`, `'large'`, or `'full'`. Default `'medium'`.
|
||||||
* **cache:** Whether the shortcode should be cached. Default `true`.
|
* **cache:** Whether the shortcode should be cached. Default `true`.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -404,7 +404,8 @@ function fictioneer_get_shortcode_tax_query( $args ) {
|
|||||||
* @param string|null $attr['lightbox'] Optional. Whether the thumbnail is opened in the lightbox. Default true.
|
* @param string|null $attr['lightbox'] Optional. Whether the thumbnail is opened in the lightbox. Default true.
|
||||||
* @param string|null $attr['thumbnail'] Optional. Whether to show the thumbnail. Default true (Customizer).
|
* @param string|null $attr['thumbnail'] Optional. Whether to show the thumbnail. Default true (Customizer).
|
||||||
* @param string|null $attr['class'] Optional. Additional CSS classes, separated by whitespace.
|
* @param string|null $attr['class'] Optional. Additional CSS classes, separated by whitespace.
|
||||||
* @param string|null $args['splide'] Configuration JSON for the Splide slider. Default empty.
|
* @param string|null $args['splide'] Optional. Configuration JSON for the Splide slider. Default empty.
|
||||||
|
* @param string|null $args['quality'] Optional. Size of the images. Default 'medium'.
|
||||||
*
|
*
|
||||||
* @return string The captured shortcode HTML.
|
* @return string The captured shortcode HTML.
|
||||||
*/
|
*/
|
||||||
@ -418,9 +419,10 @@ function fictioneer_shortcode_showcase( $attr ) {
|
|||||||
// Defaults
|
// Defaults
|
||||||
$args = fictioneer_get_default_shortcode_args( $attr, 8 );
|
$args = fictioneer_get_default_shortcode_args( $attr, 8 );
|
||||||
|
|
||||||
// Height/Width
|
// Height/Width/Quality
|
||||||
$args['height'] = sanitize_text_field( $attr['height'] ?? '' );
|
$args['height'] = sanitize_text_field( $attr['height'] ?? '' );
|
||||||
$args['min_width'] = sanitize_text_field( $attr['min_width'] ?? '' );
|
$args['min_width'] = sanitize_text_field( $attr['min_width'] ?? '' );
|
||||||
|
$args['quality'] = sanitize_text_field( $attr['quality'] ?? 'medium' );
|
||||||
|
|
||||||
// Specifics
|
// Specifics
|
||||||
$args['no_cap'] = filter_var( $attr['no_cap'] ?? 0, FILTER_VALIDATE_BOOLEAN );
|
$args['no_cap'] = filter_var( $attr['no_cap'] ?? 0, FILTER_VALIDATE_BOOLEAN );
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
* @internal $args['height'] Override the item height. Default empty.
|
* @internal $args['height'] Override the item height. Default empty.
|
||||||
* @internal $args['min_width'] Override the item minimum width. Default empty.
|
* @internal $args['min_width'] Override the item minimum width. Default empty.
|
||||||
* @internal $args['aspect_ratio'] Aspect ratio of the item. Default empty.
|
* @internal $args['aspect_ratio'] Aspect ratio of the item. Default empty.
|
||||||
|
* @internal $args['quality'] Size of the images. Default 'medium'.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -195,15 +196,16 @@ if ( $args['min_width'] ) {
|
|||||||
|
|
||||||
// Output image or placeholder
|
// Output image or placeholder
|
||||||
$ratio = fictioneer_get_split_aspect_ratio( $args['aspect_ratio'] ?: '4/2' );
|
$ratio = fictioneer_get_split_aspect_ratio( $args['aspect_ratio'] ?: '4/2' );
|
||||||
|
$quality = $args['quality'] ?? 'medium';
|
||||||
|
|
||||||
if ( ! empty( $landscape_image_id ) && $ratio[0] - $ratio[1] > 1 ) {
|
if ( ! empty( $landscape_image_id ) && $ratio[0] - $ratio[1] > 1 ) {
|
||||||
echo wp_get_attachment_image( $landscape_image_id, 'medium', false, $image_args );
|
echo wp_get_attachment_image( $landscape_image_id, $quality, false, $image_args );
|
||||||
} elseif ( has_post_thumbnail() ) {
|
} elseif ( has_post_thumbnail() ) {
|
||||||
the_post_thumbnail( 'medium', $image_args );
|
the_post_thumbnail( $quality, $image_args );
|
||||||
} elseif ( $story_id && has_post_thumbnail( $story_id ) ) {
|
} elseif ( $story_id && has_post_thumbnail( $story_id ) ) {
|
||||||
echo get_the_post_thumbnail( $story_id, 'medium', $image_args );
|
echo get_the_post_thumbnail( $story_id, $quality, $image_args );
|
||||||
} elseif ( $default_cover_id = get_theme_mod( 'default_story_cover', 0 ) ) {
|
} elseif ( $default_cover_id = get_theme_mod( 'default_story_cover', 0 ) ) {
|
||||||
echo wp_get_attachment_image( $default_cover_id, 'medium', false, $image_args );
|
echo wp_get_attachment_image( $default_cover_id, $quality, false, $image_args );
|
||||||
} else {
|
} else {
|
||||||
echo '<div class="showcase__image _no-cover"></div>';
|
echo '<div class="showcase__image _no-cover"></div>';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user