How can I fetch media.id in a .js file for image separation?

How can I fetch media.id in a .js file for image separation?

hazzardt
Excursionist
22 0 4

Hello,

 

I have a function inside of my .js.liquid file which creates a carousel on a button click. But in order to get my second part of script working, I need to be able to seperate images based on their image.id. Doing it on a main proudct page wasn't hard but generating the media.id output for each image seems a bit hard for me to figure it out.

 

Basically this piece of code gets me the product images I need, but the "img-data" part I can't figure it out:

 

 

    $(images).each(function (i,src) {
      thumbnailContainer.append('<img src="' + src +'" img-data="' + media.id + '" alt="qv-img" class="lazyload">');
    });

 

 Would appreciate some pointers. 

Replies 0 (0)