Add lightbox shortcode param

This commit is contained in:
Tetrakern 2024-04-18 16:09:27 +02:00
parent 5ededb0bf5
commit 5df8f19485
12 changed files with 21 additions and 3 deletions

View File

@ -482,6 +482,7 @@ Renders a multi-column grid of paginated medium cards ordered by publishing date
* **rel:** Relationship between different taxonomies, either `AND` or `OR`. Default `AND`. * **rel:** Relationship between different taxonomies, either `AND` or `OR`. Default `AND`.
* **seamless:** Whether to remove the gap between the image and frame. Default `false`. * **seamless:** Whether to remove the gap between the image and frame. Default `false`.
* **thumbnail:** Whether to show the thumbnail/cover image. Default `true`. * **thumbnail:** Whether to show the thumbnail/cover image. Default `true`.
* **lightbox:** Whether clicking on the thumbnail/cover image opens the lightbox or post link. Default `true`.
* **aspect_ratio:** CSS [aspect-ratio](https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio) value for the image (X/Y). Default `3/1`. * **aspect_ratio:** CSS [aspect-ratio](https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio) value for the image (X/Y). Default `3/1`.
* **class:** Additional CSS classes, separated by whitespace. * **class:** Additional CSS classes, separated by whitespace.
@ -640,6 +641,7 @@ Renders a multi-column grid of small cards, showing the latest four chapters ord
* **vertical:** Whether to render the cards with the image on top. Default `false`. * **vertical:** Whether to render the cards with the image on top. Default `false`.
* **seamless:** Whether to remove the gap between the image and frame (X/Y; vertical only). Default `false`. * **seamless:** Whether to remove the gap between the image and frame (X/Y; vertical only). Default `false`.
* **thumbnail:** Whether to show the thumbnail/cover image. Default `true`. * **thumbnail:** Whether to show the thumbnail/cover image. Default `true`.
* **lightbox:** Whether clicking on the thumbnail/cover image opens the lightbox or post link. Default `true`.
* **aspect_ratio:** CSS [aspect-ratio](https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio) value for the image (X/Y; vertical only). Default `3/1`. * **aspect_ratio:** CSS [aspect-ratio](https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio) value for the image (X/Y; vertical only). Default `3/1`.
* **class:** Additional CSS classes, separated by whitespace. * **class:** Additional CSS classes, separated by whitespace.
@ -717,6 +719,7 @@ Renders a multi-column grid of small cards, showing the latest four recommendati
* **vertical:** Whether to render the cards with the image on top. Default `false`. * **vertical:** Whether to render the cards with the image on top. Default `false`.
* **seamless:** Whether to remove the gap between the image and frame (X/Y; vertical only). Default `false`. * **seamless:** Whether to remove the gap between the image and frame (X/Y; vertical only). Default `false`.
* **thumbnail:** Whether to show the thumbnail/cover image. Default `true`. * **thumbnail:** Whether to show the thumbnail/cover image. Default `true`.
* **lightbox:** Whether clicking on the thumbnail/cover image opens the lightbox or post link. Default `true`.
* **aspect_ratio:** CSS [aspect-ratio](https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio) value for the image (X/Y; vertical only). Default `3/1`. * **aspect_ratio:** CSS [aspect-ratio](https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio) value for the image (X/Y; vertical only). Default `3/1`.
* **class:** Additional CSS classes, separated by whitespace. * **class:** Additional CSS classes, separated by whitespace.
@ -763,6 +766,7 @@ Renders a multi-column grid of small cards, showing the latest four stories orde
* **vertical:** Whether to render the cards with the image on top. Default `false`. * **vertical:** Whether to render the cards with the image on top. Default `false`.
* **seamless:** Whether to remove the gap between the image and frame (X/Y; vertical only). Default `false`. * **seamless:** Whether to remove the gap between the image and frame (X/Y; vertical only). Default `false`.
* **thumbnail:** Whether to show the thumbnail/cover image. Default `true`. * **thumbnail:** Whether to show the thumbnail/cover image. Default `true`.
* **lightbox:** Whether clicking on the thumbnail/cover image opens the lightbox or post link. Default `true`.
* **aspect_ratio:** CSS [aspect-ratio](https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio) value for the image (X/Y; vertical only). Default `3/1`. * **aspect_ratio:** CSS [aspect-ratio](https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio) value for the image (X/Y; vertical only). Default `3/1`.
* **class:** Additional CSS classes, separated by whitespace. * **class:** Additional CSS classes, separated by whitespace.
@ -808,6 +812,7 @@ Renders a multi-column grid of small cards, showing the latest four updated stor
* **vertical:** Whether to render the cards with the image on top. Default `false`. * **vertical:** Whether to render the cards with the image on top. Default `false`.
* **seamless:** Whether to remove the gap between the image and frame (X/Y; vertical only). Default `false`. * **seamless:** Whether to remove the gap between the image and frame (X/Y; vertical only). Default `false`.
* **thumbnail:** Whether to show the thumbnail/cover image. Default `true`. * **thumbnail:** Whether to show the thumbnail/cover image. Default `true`.
* **lightbox:** Whether clicking on the thumbnail/cover image opens the lightbox or post link. Default `true`.
* **aspect_ratio:** CSS [aspect-ratio](https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio) value for the image (X/Y; vertical only). Default `3/1`. * **aspect_ratio:** CSS [aspect-ratio](https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio) value for the image (X/Y; vertical only). Default `3/1`.
* **class:** Additional CSS classes, separated by whitespace. * **class:** Additional CSS classes, separated by whitespace.

View File

@ -791,12 +791,13 @@ if ( ! function_exists( 'fictioneer_output_small_card_thumbnail' ) ) {
function fictioneer_output_small_card_thumbnail( $args ) { function fictioneer_output_small_card_thumbnail( $args ) {
// Setup // Setup
$post_id = $args['post_id'] ?? get_the_ID(); $post_id = $args['post_id'] ?? get_the_ID();
$lightbox_attribute = fictioneer_get_lightbox_attribute();
$title = esc_attr( wp_strip_all_tags( $args['title'] ?? __( 'Thumbnail', 'fictioneer' ) ) ); $title = esc_attr( wp_strip_all_tags( $args['title'] ?? __( 'Thumbnail', 'fictioneer' ) ) );
$classes = $args['classes'] ?? ''; $classes = $args['classes'] ?? '';
$text_icon = $args['text_icon'] ?? ''; $text_icon = $args['text_icon'] ?? '';
$permalink = $args['permalink'] ?? get_permalink( $post_id ); $permalink = $args['permalink'] ?? get_permalink( $post_id );
$vertical = $args['vertical'] ?? 0; $vertical = $args['vertical'] ?? 0;
$lightbox = $args['lightbox'] ?? 1;
$lightbox_attribute = $lightbox ? fictioneer_get_lightbox_attribute() : '';
// Get sized thumbnail, full thumbnail, and img tag // Get sized thumbnail, full thumbnail, and img tag
$thumbnails = $args['thumbnails'] ?? fictioneer_get_small_card_thumbnail( $thumbnails = $args['thumbnails'] ?? fictioneer_get_small_card_thumbnail(
@ -813,11 +814,13 @@ if ( ! function_exists( 'fictioneer_output_small_card_thumbnail' ) ) {
// Build // Build
if ( $thumbnails['thumbnail'] ?? 0 ) { if ( $thumbnails['thumbnail'] ?? 0 ) {
// Link (lightbox) with image tag // Link (lightbox) with image tag
echo "<a href='{$thumbnails['thumbnail_full_url']}' class='{$classes}' title='{$title}' {$lightbox_attribute}>{$thumbnails['thumbnail']}</a>"; $url = $lightbox ? $thumbnails['thumbnail_full_url'] : $permalink;
echo "<a href='{$url}' class='{$classes}' title='{$title}' {$lightbox_attribute}>{$thumbnails['thumbnail']}</a>";
} elseif ( $vertical ) { } elseif ( $vertical ) {
// Placeholder image // Placeholder image
$placeholder = fictioneer_get_placeholder_image(); $placeholder = fictioneer_get_placeholder_image();
$url = $placeholder['thumbnail_full_url']; $url = $lightbox ? $placeholder['thumbnail_full_url'] : $permalink;
$classes .= ' _placeholder'; $classes .= ' _placeholder';
if ( $placeholder['generated'] ?? 0 ) { if ( $placeholder['generated'] ?? 0 ) {

View File

@ -197,6 +197,7 @@ function fictioneer_get_default_shortcode_args( $attr, $def_count = -1 ) {
'seamless' => filter_var( $attr['seamless'] ?? 0, FILTER_VALIDATE_BOOLEAN ), 'seamless' => filter_var( $attr['seamless'] ?? 0, FILTER_VALIDATE_BOOLEAN ),
'aspect_ratio' => sanitize_css_aspect_ratio( $attr['aspect_ratio'] ?? '' ), 'aspect_ratio' => sanitize_css_aspect_ratio( $attr['aspect_ratio'] ?? '' ),
'thumbnail' => filter_var( $attr['thumbnail'] ?? 1, FILTER_VALIDATE_BOOLEAN ), 'thumbnail' => filter_var( $attr['thumbnail'] ?? 1, FILTER_VALIDATE_BOOLEAN ),
'lightbox' => filter_var( $attr['lightbox'] ?? 1, FILTER_VALIDATE_BOOLEAN ),
'classes' => esc_attr( wp_strip_all_tags( $attr['class'] ?? '' ) ) 'classes' => esc_attr( wp_strip_all_tags( $attr['class'] ?? '' ) )
); );

View File

@ -176,6 +176,7 @@ $pag_args = array(
'title' => $title, 'title' => $title,
'classes' => 'card__image _article cell-img', 'classes' => 'card__image _article cell-img',
'permalink' => $permalink, 'permalink' => $permalink,
'lightbox' => $args['lightbox'],
'vertical' => 1, 'vertical' => 1,
'seamless' => $args['seamless'], 'seamless' => $args['seamless'],
'aspect_ratio' => $args['aspect_ratio'] ?: '3/1' 'aspect_ratio' => $args['aspect_ratio'] ?: '3/1'

View File

@ -190,6 +190,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
'title' => $title, 'title' => $title,
'classes' => 'card__image cell-img', 'classes' => 'card__image cell-img',
'permalink' => get_permalink(), 'permalink' => get_permalink(),
'lightbox' => $args['lightbox'],
'vertical' => $args['vertical'], 'vertical' => $args['vertical'],
'seamless' => $args['seamless'], 'seamless' => $args['seamless'],
'aspect_ratio' => $args['aspect_ratio'], 'aspect_ratio' => $args['aspect_ratio'],

View File

@ -204,6 +204,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
'title' => $title, 'title' => $title,
'classes' => 'card__image cell-img', 'classes' => 'card__image cell-img',
'permalink' => get_permalink(), 'permalink' => get_permalink(),
'lightbox' => $args['lightbox'],
'vertical' => $args['vertical'], 'vertical' => $args['vertical'],
'seamless' => $args['seamless'], 'seamless' => $args['seamless'],
'aspect_ratio' => $args['aspect_ratio'], 'aspect_ratio' => $args['aspect_ratio'],

View File

@ -166,6 +166,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
'title' => $title, 'title' => $title,
'classes' => 'card__image cell-img', 'classes' => 'card__image cell-img',
'permalink' => get_permalink(), 'permalink' => get_permalink(),
'lightbox' => $args['lightbox'],
'vertical' => $args['vertical'], 'vertical' => $args['vertical'],
'seamless' => $args['seamless'], 'seamless' => $args['seamless'],
'aspect_ratio' => $args['aspect_ratio'] 'aspect_ratio' => $args['aspect_ratio']

View File

@ -181,6 +181,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
'title' => $title, 'title' => $title,
'classes' => 'card__image cell-img', 'classes' => 'card__image cell-img',
'permalink' => get_permalink(), 'permalink' => get_permalink(),
'lightbox' => $args['lightbox'],
'vertical' => $args['vertical'], 'vertical' => $args['vertical'],
'seamless' => $args['seamless'], 'seamless' => $args['seamless'],
'aspect_ratio' => $args['aspect_ratio'] 'aspect_ratio' => $args['aspect_ratio']

View File

@ -191,6 +191,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
'title' => $story['title'], 'title' => $story['title'],
'classes' => 'card__image cell-img', 'classes' => 'card__image cell-img',
'permalink' => $story_link, 'permalink' => $story_link,
'lightbox' => $args['lightbox'],
'vertical' => $args['vertical'], 'vertical' => $args['vertical'],
'seamless' => $args['seamless'], 'seamless' => $args['seamless'],
'aspect_ratio' => $args['aspect_ratio'] 'aspect_ratio' => $args['aspect_ratio']

View File

@ -179,6 +179,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
'title' => $story['title'], 'title' => $story['title'],
'classes' => 'card__image cell-img', 'classes' => 'card__image cell-img',
'permalink' => $story_link, 'permalink' => $story_link,
'lightbox' => $args['lightbox'],
'vertical' => $args['vertical'], 'vertical' => $args['vertical'],
'seamless' => $args['seamless'], 'seamless' => $args['seamless'],
'aspect_ratio' => $args['aspect_ratio'] 'aspect_ratio' => $args['aspect_ratio']

View File

@ -219,6 +219,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
'title' => $story['title'], 'title' => $story['title'],
'classes' => 'card__image cell-img', 'classes' => 'card__image cell-img',
'permalink' => $story_link, 'permalink' => $story_link,
'lightbox' => $args['lightbox'],
'vertical' => $args['vertical'], 'vertical' => $args['vertical'],
'seamless' => $args['seamless'], 'seamless' => $args['seamless'],
'aspect_ratio' => $args['aspect_ratio'] 'aspect_ratio' => $args['aspect_ratio']

View File

@ -226,6 +226,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
'title' => $story['title'], 'title' => $story['title'],
'classes' => 'card__image cell-img', 'classes' => 'card__image cell-img',
'permalink' => $story_link, 'permalink' => $story_link,
'lightbox' => $args['lightbox'],
'vertical' => $args['vertical'], 'vertical' => $args['vertical'],
'seamless' => $args['seamless'], 'seamless' => $args['seamless'],
'aspect_ratio' => $args['aspect_ratio'] 'aspect_ratio' => $args['aspect_ratio']