Have you tried, instead of:
const currentItem = $w("#gallery1").currentItem;
this:
const currentItem = $w("#gallery1").currentItem.src;
Note: if you get into trouble exporting a Wix-image (with the src":“wix:image://v1/99bc1c6f66…” -syntax to something that can be reached from outside: that has been asked and solved many times here on the Forum