Filtering images in print mode

This commit is contained in:
Eric van der Vlist 2025-03-27 21:33:45 +01:00
parent 9ba1b49cd2
commit 7e9fde87bc
2 changed files with 28 additions and 2 deletions

View File

@ -12,7 +12,20 @@
'columns' => 2, 'columns' => 2,
'size' => 'medium', 'size' => 'medium',
'link' => 'file', '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); echo gallery_shortcode($gallery_attributes);
?> ?>
</div> </div>

View File

@ -12,7 +12,20 @@
'columns' => 2, 'columns' => 2,
'size' => 'medium', 'size' => 'medium',
'link' => 'file', '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); echo gallery_shortcode($gallery_attributes);
?> ?>
</div> </div>