Javacode to read in all videos in a gallery, and automatically insert the filenames into a single <video> tag?
Posted: 23 Jul 2025, 02:43
Hello Karl & anybody else,
This question pertains to videos (MP4s) that are played using <video> tags, which is defined in its gallery on the Settings|Content page.
I have a little over 500 videos, which I am dreading having to manually add each of them into the Content page.
I am curious if it's possible, through some Javascript code, to be able to automatically read in every MP4 file within that gallery, and then have the Javascript code automatically insert the actual video filename into each <video> tag (in the below sample code, it would insert the actual filename where autofilename.mp4 is shown).
All of my MP4 files are located in a subfolder (gallery_items_folder in the below sample code), and that subfolder is hidden, so none of the actual MP4 files are displayed, and the gallery itself is empty, and uses only what is coded in the Content page.
I am also hoping that I will be able to use only 1 single <video> tag (as shown above), instead of 500+ video tags.
I got the idea from another post HERE from a couple of years ago, but I have no idea if that project was taken any further.
So, anyone know if what I am try to accomplish is doable? I know absolutely nothing about Javascript.
Thanks in advance & have yourselves a great day.
Regards,
John
This question pertains to videos (MP4s) that are played using <video> tags, which is defined in its gallery on the Settings|Content page.
I have a little over 500 videos, which I am dreading having to manually add each of them into the Content page.
I am curious if it's possible, through some Javascript code, to be able to automatically read in every MP4 file within that gallery, and then have the Javascript code automatically insert the actual video filename into each <video> tag (in the below sample code, it would insert the actual filename where autofilename.mp4 is shown).
All of my MP4 files are located in a subfolder (gallery_items_folder in the below sample code), and that subfolder is hidden, so none of the actual MP4 files are displayed, and the gallery itself is empty, and uses only what is coded in the Content page.
Code
<div>
<center>
<!-- Evenly adjust content within a block-grid -->
<!-- Read more: http://foundation.zurb.com/sites/docs/v/5.5.3/components/block_grid.html -->
<ul class='small-block-grid-7 medium-block-grid-7 large-block-grid-7'>
<li>
<div>
<video class="x3-style-frame" preload="metadata" controls muted autoplay loop
controlslist="nodownload noplaybackrate" width="100%" title="autofilename">
<source src="{{path}}gallery_items_folder/autofilename.mp4"
type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
</li>
</ul>
</center>
</div>I got the idea from another post HERE from a couple of years ago, but I have no idea if that project was taken any further.
So, anyone know if what I am try to accomplish is doable? I know absolutely nothing about Javascript.
Thanks in advance & have yourselves a great day.
Regards,
John