.slice() is not working

I am trying to pull the source from a picture in my repeater and then send it to my lightbox. When I print to console the source looks like this:

console.log(clickedItemData . iIMG); //this returns

wix:image://v1/61dee1_002a705a35964056b3d162cb09da44a4~mv2.jpg/card.jpg#originWidth=226&originHeight=310

This source isn’t working as-is (I assume the ‘#’ is throwing it off) so I need to manipulate it using .slice. Please see my attempt below.

export function repeatButton_click ( event ) {
let $item = $w . at ( event . context );
let clickedItemData = $item ( “#dataset1” ). getCurrentItem ();

//find jpg location to build image url 
**var**  length  =  clickedItemData . iImg . indexOf ( "jpg" );  

//length is coming back correctly
var urlstring = clickedItemData . iIMG ; // returns undefined
var url = urlstring . slice ( 0 , length + 3 ) //throws error as it cannot read an undefined variable
console . log ( urlstring , length ); //returns undefined 59
wixWindow . openLightbox ( “TestLight” ,
{
“pageSend1” : clickedItemData . title , //works
“pageSend2” : String ( clickedItemData . iCost ), //works
“pageSend3” : url //not working
})

Is it iImg or iIMG ?

You say this works:

var length = clickedItemData.iImg.indexOf("jpg");

…and it uses iImg.

You have this line (which you say doesn’t work):

var urlstring = clickedItemData.iIMG; // returns undefined

You want this:

var urlstring = clickedItemData.iImg; // returns undefined

OMG. That’s what I get for coding at almost 2am. Thanks.