This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Ben
Ben

Hi, I'm building kind of an image slider. I want the user have two choices to choose the images- direct upload and select file from the assets folder. How can i list all available images and how to implement this?

Thanks, Ben

Last updated

jkh4078
jkh4078

I would like to know the same thing.

d.negativa
jkh4078
jkh4078

Hmm dont know if this is correct or the October way, bit I solved it like this.

    $theme = Theme::getEditTheme();
    $files = [];
    $di = new \RecursiveDirectoryIterator($theme->getActiveTheme()->getPath() . '/assets/images/');
    foreach (new \RecursiveIteratorIterator($di) as $filename => $file) {
        if ($file->getFilename() == "." OR $file->getFilename() == "..")
            continue;
        $files[] = str_replace($theme->getActiveTheme()->getPath(), '', $filename);
    }

    return $files;

Last updated

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.