1/* 2 * Copyright 2012-2024, Theia Smart Thumbnails, WeCodePixels, https://wecodepixels.com 3 */ 4var tst = tst || {}; 5 6jQuery(document).on('ready', function () { 7 var $ = jQuery; 8 tst.adjustBackgroundImages = function (tstLoadedImages) { 9 // Index background images. 10 var imageElements = []; 11 $('*').each(function () { 12 var $this = $(this); 13 var backgroundImage = $this.css('backgroundImage'); 14 15 // Fix for avia-slideshow. 16 if (!backgroundImage || backgroundImage === 'none') { 17 backgroundImage = $this.attr('data-img-url'); 18 } 19 20 // Only applies to cover images. 21 if (!backgroundImage || $this.css('backgroundSize') !== 'cover') { 22 return; 23 } 24 25 imageElements.push({ 26 element: $this, 27 url: backgroundImage, 28 type: 'background', 29 }); 30 }); 31 32 // Index image tags. 33 $('img').each(function () { 34 var $this = $(this); 35 var src = $this.attr('src'); 36 37 // Only applies to object-fit images. 38 if (!src || $(this).css('objectFit') !== 'cover') { 39 return; 40 } 41 42 imageElements.push({ 43 element: $this, 44 url: src, 45 type: 'image', 46 }); 47 }); 48 49 // Browse through all image IDs. 50 for (var id in tstLoadedImages) { 51 var image = tstLoadedImages[id]; 52 53 // Browse through all URLs. 54 for (var i = 0; i < image.urls.length; i++) { 55 var url = image.urls[i]; 56 57 // Find elements using this URL. 58 for (var j = 0; j < imageElements.length; j++) { 59 var imageElement = imageElements[j]; 60 61 // Search for URL directly. 62 var found = imageElement.url.indexOf(url) !== -1; 63 64 // Try to decode URL. 65 if (!found) { 66 try { 67 if (decodeURIComponent(imageElement.url).indexOf(url) !== -1) { 68 found = true; 69 } 70 } catch (e) { 71 } 72 } 73 74 if (found) { 75 var x = image.focusPointX * 100 + '%'; 76 var y = image.focusPointY * 100 + '%'; 77 78 if (imageElement.type === 'background') { 79 imageElement.element 80 .css('background-position-x', x) 81 .css('background-position-y', y); 82 } else if (imageElement.type === 'image') { 83 imageElement.element.css('object-position', x + ' ' + y); 84 } 85 } 86 } 87 } 88 } 89 }; 90 91 if (typeof tstLoadedImages !== 'undefined') { 92 tst.adjustBackgroundImages(tstLoadedImages); 93 } 94});
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.