I am looking for a way to creating dynamic urls with kirby in order to render a random image from the array of images in my contact page contents folder
I was thinking something like this might work but no luck
var bg = [‘<?= $page->images() ?>’];
Here is my code which works fine but looking to not use static urls
function change() {
var bg = ['content/5_contact/dawn.jpg', 'content/5_contact/galore.jpeg'];
$('.contact__image').css({
'background' : 'url('+ bg[Math.floor(Math.random() * bg.length)] + ') no-repeat', 'background-size' : 'cover', 'background-position': 'center'
});
}
change();