Restructuring multiple variables into an array
I don't quite understand why you are using individual variables for the various items since all you are doing is outputting them as a group. It would be much cleaner to collect them into a collection. Perhaps something like this:

//Images
List images = [
  properties["headerImage"],
  properties["sidebarImage"],
  properties["footerImage"]
]

//Videos
List videos = [
  properties["mainVideo"],
  properties["sidebarVideo"],
  properties["overviewImage"]
]


With the output looking like this:

$(document).ready(function () {
    $('.mediaGallery').mediaFilters({
        images: '${images.join(",")}',
        videos: '${videos.join(",")}',            
    });
});


That improves readability, and with the example you have given doesn't impact functionality.