From 7e9fde87bc7090a75a94764f3e0b0bb9d7071325 Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Thu, 27 Mar 2025 21:33:45 +0100 Subject: [PATCH] Filtering images in print mode --- build/wp-printable-gallery/render.php | 15 ++++++++++++++- src/wp-printable-gallery/render.php | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/build/wp-printable-gallery/render.php b/build/wp-printable-gallery/render.php index e40463a..3ae35be 100644 --- a/build/wp-printable-gallery/render.php +++ b/build/wp-printable-gallery/render.php @@ -12,7 +12,20 @@ 'columns' => 2, 'size' => 'medium', 'link' => 'file', - ]; + ]; + if ( array_key_exists('print', $_GET)) { + $images = get_attached_media('image'); + $ids = array(); + foreach ($images as $image_id =>$image) { + if (get_post_meta($image_id, 'wpdfh.print', true) !== '') { + $ids[] = "$image_id"; + } + } + $gallery_attributes['ids'] = implode(',', $ids); +// error_log('PHP: rendering printable gallery, $images: '.print_r($images, true), 0); +// error_log('PHP: rendering printable gallery, $_GET: '.print_r($_GET, true), 0); + } + echo gallery_shortcode($gallery_attributes); ?> diff --git a/src/wp-printable-gallery/render.php b/src/wp-printable-gallery/render.php index e40463a..3ae35be 100644 --- a/src/wp-printable-gallery/render.php +++ b/src/wp-printable-gallery/render.php @@ -12,7 +12,20 @@ 'columns' => 2, 'size' => 'medium', 'link' => 'file', - ]; + ]; + if ( array_key_exists('print', $_GET)) { + $images = get_attached_media('image'); + $ids = array(); + foreach ($images as $image_id =>$image) { + if (get_post_meta($image_id, 'wpdfh.print', true) !== '') { + $ids[] = "$image_id"; + } + } + $gallery_attributes['ids'] = implode(',', $ids); +// error_log('PHP: rendering printable gallery, $images: '.print_r($images, true), 0); +// error_log('PHP: rendering printable gallery, $_GET: '.print_r($_GET, true), 0); + } + echo gallery_shortcode($gallery_attributes); ?>