Display all uploaded images (regardless of parent post) in a gallery?

Post Reply
kr428
Sr. Bludit
Posts: 38
Joined: Thu Jan 05, 2023 9:07 pm
Has thanked: 11 times
Been thanked: 3 times

Alls; I do have a bunch of posts that contain images embedded or attached to it. Is it (easily) possible to add a global "gallery" displaying all these images in one view, maybe linking back to the actual post that contained it? Currently I'm using a category for that which is okay but the view leaves a bit to be desired...
Any ideas?
Thanks very much and best regards,
Kristian
User avatar
Misteric
Ssr. Bludit
Posts: 16
Joined: Mon Aug 08, 2022 2:55 pm
Has thanked: 3 times
Been thanked: 6 times

Hi Kristian,

You can use the php GLOB or SCANDIR function, like this:

Code: Select all

<?php $dir = "../*.png"; // upload folder to list png files
foreach (glob($dir) as $filename) {
   echo $filename . "\n";
}?> 

Code: Select all

<?php $dir = "/images/";
$files = scandir($dir); ?>
Kind regards,

Misteric
Post Reply