File Manager problem

Permalink
My theme has a script in it that changes the background image of the body of the page every few seconds. It pulls those background images from the /images folder in my theme. I want the client to be able to change these images as needed. I can't figure out how to accomplish this through concrete5's CMS, not FTP

If they upload them through the file manager it seems to assign the image to a randomly named folder, even if I tried the "replace" option it changes the folder.

Right now I'm using "$this->getThemePath()" in my "img src" path. Is there a php snippet that might instead point to all the subfolders in root/files/?
Thank you

 
A3020 replied on at Permalink Reply
A3020
Hi Chris,

It's best to use 'File Sets' for this. Create one and put a few images in it. Then use something like this in your script:

<?php
$files = FileSet::getFilesBySetID(12323123);
if($files){
foreach($files as $f){
echo $file->getVersion()->getRelativePath();
}

//or
$f = $files[array_rand($files)];
echo $f->getVersion()->getRelativePath();
}
JohntheFish replied on at Permalink Reply
JohntheFish
Have a look at the List Files From Set addon and the associated Image Files templates for a more detailed example of what @akodde is suggesting.