Jul 13, 202212:06 AM - edited Jul 13, 202212:07 AM
Member
Loop Through Files
SOLVE
I'm working on building a module that will automatically build a marquee showcasing a set of images. I want to make it so that the images are automatically pulled from a folder in the files section of our Kumospace account. The intention is that admins can add or remove images from the folder in order to update the list of images displayed by the module. Is there any way to do this? Other's who have worked on our site have used jquery to get specific images from the files, but I'm having trouble getting all images from an entire folder.
I don't understand much what you are trying to achieve here, but if you have a set of images inside a folder and you want to use them in your modules, you could copy the link to the folder into your module as scr attribute of your images and play with the naming of the images and a loop.
For example, you could have the following code:
{% for x in range(0,5) %}
<img src="https://yourdomain.com/path-to-folder/file-{{x}}.jpg"/>
{% endfor %}
And your images should have the following names:
file-0.jpg
file-1.jpg
file-2.jpg
file-3.jpg
file-4.jpg
file-5.jpg
If content editors want to change an image, they just need to replace them inside the folder and keep the same name (and file extension).
Hope this brings some light to your issue 😊
Did my answer help you? Mark it as a solution ✅
Do you need help with your site? Book time with me:
I don't understand much what you are trying to achieve here, but if you have a set of images inside a folder and you want to use them in your modules, you could copy the link to the folder into your module as scr attribute of your images and play with the naming of the images and a loop.
For example, you could have the following code:
{% for x in range(0,5) %}
<img src="https://yourdomain.com/path-to-folder/file-{{x}}.jpg"/>
{% endfor %}
And your images should have the following names:
file-0.jpg
file-1.jpg
file-2.jpg
file-3.jpg
file-4.jpg
file-5.jpg
If content editors want to change an image, they just need to replace them inside the folder and keep the same name (and file extension).
Hope this brings some light to your issue 😊
Did my answer help you? Mark it as a solution ✅
Do you need help with your site? Book time with me:
Hey, thanks for the suggestion. We have something similar in place in one spot, but we were hoping to manage to make it more dynamic. Looks like that isn't possible at this time though.