Boob Tape That’s Built For You
Tell Your Bra To Take The Day Off
(function() {
function filterGalleryByVariant(variant) {
if (!variant) return;
const colorName = variant.option1 ? variant.option1.toLowerCase() : null;
if (!colorName) return;
const gallery = document.querySelector('media-gallery');
if (!gallery) return;
const viewer = gallery.querySelector('[id^="GalleryViewer"]');
const thumbnails = gallery.querySelector('[id^="GalleryThumbnails"]');
if (!viewer) return;
const mediaItems = viewer.querySelectorAll('[data-media-id]');
let firstMatchId = null;
mediaItems.forEach(item => {
const img = item.querySelector('img');
const alt = img ? img.getAttribute('alt') : '';
const matches = alt && alt.toLowerCase().includes(colorName);
item.style.display = matches ? '' : 'none';
if (matches && !firstMatchId) firstMatchId = item.dataset.mediaId;
});
if (thumbnails) {
thumbnails.querySelectorAll('[data-target]').forEach(thumb => {
const img = thumb.querySelector('img');
const alt = img ? img.getAttribute('alt') : '';
const matches = alt && alt.toLowerCase().includes(colorName);
thumb.style.display = matches ? '' : 'none';
});
}
if (firstMatchId) gallery.setActiveMedia(firstMatchId, true);
}
document.addEventListener('variant:change', function(e) {
filterGalleryByVariant(e.detail && e.detail.variant);
});
// Fire on page load
document.addEventListener('DOMContentLoaded', function() {
const form = document.querySelector('form[action="/cart/add"]');
const variantInput = form && form.querySelector('[name="id"]');
if (!variantInput) return;
fetch('/products/barely-tape.js')
.then(r => r.json())
.then(product => {
const variant = product.variants.find(v => String(v.id) === variantInput.value);
filterGalleryByVariant(variant);
});
});
})();