First you hopefully created that in a child theme so it wont be lost in the next update.
Which image slider plugin are you speaking of, is it Weaver show slider?
Are the images in question in the database, if so have you created a slider the regular way using these images, and is you question how to incorporate the result of the slider shortcode in your PHP template?
If this is the question, @weaver would have to comment
There is no API in Weaver or Weaver Show Sliders to accommodate direct manipulation of slider images via PHP.
If your images are defined by a custom post type (ACF gallery, perhaps? I don’t know myself.), then you might not even have to iterate through the images directly, but could use a [show_posts] + [show_sliders] filter directly via a shortcode.
But this adding JS to custom PHP is way beyond the level of support.