1document.addEventListener('DOMContentLoaded', function() { 2 if (ei_js_data.disable_fallback_image) return; 3 const fallbackImageUrl = ei_js_data.fallbackimage; // Admins should replace this with the correct URL. 4 5 function handleImageError(imgElement) { 6 // Check if the fallback has already been applied to avoid recursion 7 if (imgElement.dataset.fallbackApplied) { 8 console.error('Fallback image also failed to load:', imgElement.src); 9 return; 10 } 11 12 console.log('Loading fallback image for:', imgElement.src); 13 imgElement.src = fallbackImageUrl; 14 imgElement.dataset.fallbackApplied = 'true'; // Mark this image to avoid recursion 15 } 16 17 // Attach error handler to an image element 18 function attachErrorHandler(imgElement) { 19 imgElement.onerror = function() { 20 handleImageError(imgElement); 21 }; 22 23 // Force trigger error event if image is complete but has failed to load properly 24 if (imgElement.complete && (imgElement.naturalHeight === 0 || imgElement.naturalWidth === 0)) { 25 handleImageError(imgElement); 26 } 27 } 28 29 // MutationObserver to handle dynamically added images 30 const observer = new MutationObserver(function(mutations) { 31 mutations.forEach(function(mutation) { 32 mutation.addedNodes.forEach(function(node) { 33 if (node.tagName === 'IMG') { 34 attachErrorHandler(node); 35 } 36 }); 37 }); 38 }); 39 40 observer.observe(document.body, { 41 childList: true, 42 subtree: true 43 }); 44 45 // Attach error handlers to all existing images 46 document.querySelectorAll('img').forEach(attachErrorHandler); 47}); 48console.log('listening for errors on images'); 49 50 51let ExternalImagesVariationHandlerEnabled = true; 52 53jQuery(document).on( "show_variation", ".single_variation_wrap", function ( event, variation ) { 54 if (!ExternalImagesVariationHandlerEnabled) { 55 return; 56 } 57 // Fired when the user selects all the required dropdowns / attributes 58 // and a final variation is selected / shown 59 60 if (ei_js_data.disable_variation_js) { 61 return; 62 } 63 64 var variation_id = variation.variation_id; 65 66 jQuery.ajax( 67 { 68 method: "GET", 69 url: ei_js_data.ajaxurl, 70 dataType: "json", 71 data: { 72 action: "ei_get_variation_images", 73 variation_id: variation_id, 74 nonce: ei_js_data.nonce 75 }, 76 success: function (data) { 77 // check if "https://assets.goal.com/v3/assets/bltcc7a7ffd2fbf71f5/blt0287dde108869762/64ae7a05e4133a34d018b432/Wrexham_2023-24_third_kit.png?auto=webp&format=pjpg&width=3840&quality=60" string is contained in data.main or data.thumbs and output the result 78 if (data.main.includes("https://assets.goal.com/v3/assets/bltcc7a7ffd2fbf71f5/blt0287dde108869762/64ae7a05e4133a34d018b432/Wrexham_2023-24_third_kit.png?auto=webp&format=pjpg&width=3840&quality=60")) { 79 console.log("data.main contains"); 80 } 81 if (data.thumbs.includes("https://assets.goal.com/v3/assets/bltcc7a7ffd2fbf71f5/blt0287dde108869762/64ae7a05e4133a34d018b432/Wrexham_2023-24_third_kit.png?auto=webp&format=pjpg&width=3840&quality=60")) { 82 console.log("data.thumbs contains"); 83 } 84 85 86 87 88 89 woogallery = jQuery(data.main).not('link'); // woodmart for some reason adds these link elements into the single-product/product-image.php template 90 91 var firstElement = woogallery.first(); 92 var allClasses = firstElement.attr('class'); 93 var selector = '.' + allClasses.split(' ').join('.'); 94 if (jQuery(selector).length > 0) { 95 jQuery(selector).html(firstElement.html()); 96 } else { 97 jQuery(ei_js_data.variation_gallery_wrapper_css).html(firstElement.html()); 98 } 99 jQuery(ei_js_data.variation_gallery_wrapper_css + ' .thumbnails').html(data.thumbs); 100 101 jQuery(ei_js_data.variation_gallery_wrapper_css + ' .thumbnails').css('opacity', 1).unblock(); 102 103 if (typeof woodmartThemeModule !== 'undefined' && typeof woodmartThemeModule.productImagesGallery === 'function') { 104 woodmartThemeModule.productImagesGallery(); 105 } 106 /* 107 jQuery(ei_js_data.variation_gallery_wrapper_css + ' .woocommerce-product-gallery__wrapper').slick({ 108 slidesToShow: 1, 109 slidesToScroll: 1, 110 arrows: true, 111 fade: true, 112 asNavFor: ei_js_data.variation_gallery_wrapper_css + ' .thumbnails' // Link to Thumbnail Slider
113 // other options as needed 114 }); 115 116 // Initialize Thumbnail Slider 117 jQuery(ei_js_data.variation_gallery_wrapper_css + ' .thumbnails').slick({ 118 slidesToShow: 3, // Adjust this number based on your design 119 slidesToScroll: 1, 120 asNavFor: ei_js_data.variation_gallery_wrapper_css + ' .woocommerce-product-gallery__wrapper', // Link to Main Image Slider 121 dots: false, 122 centerMode: true, 123 focusOnSelect: true 124 // other options as needed 125 }); 126 */ 127 128 }, 129 complete: function (r) { 130 console.log(r); 131 } 132 }); 133} );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.