Changeset 2760300
- Timestamp:
- 07/22/2022 01:54:33 PM (4 years ago)
- Location:
- wp-lozad/trunk
- Files:
-
- 3 edited
-
js/initLozad.js (modified) (8 diffs)
-
lozad.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-lozad/trunk/js/initLozad.js
r2755113 r2760300 4 4 5 5 init = () => { 6 this. #handle();6 this.__handle(); 7 7 } 8 8 9 #handle = () => {9 __handle = () => { 10 10 if (typeof lozad !== 'function') { 11 this. #image2x();11 this.__image2x(); 12 12 return; 13 13 } 14 14 15 this. #initLazyload();15 this.__initLazyload(); 16 16 } 17 17 18 #initLazyload = () => {18 __initLazyload = () => { 19 19 lozad('.lazyload', { 20 20 loaded: (el) => { 21 el.classList.remove('lazyload') 21 el.classList.remove('lazyload'); 22 22 } 23 23 }).observe(); 24 24 25 this. #image2x();25 this.__image2x(); 26 26 27 27 window.load = () => { … … 30 30 } 31 31 32 #urlExists = (url) => {32 __urlExists = (url) => { 33 33 const http = new XMLHttpRequest(); 34 34 http.open('HEAD', url, false); … … 37 37 } 38 38 39 #replaceImgTo2Img = (currentString) => {39 __replaceImgTo2Img = (currentString) => { 40 40 if (!currentString) { 41 41 return ''; … … 47 47 } 48 48 49 #handleBgImageTo2xBg = () => {49 __handleBgImageTo2xBg = () => { 50 50 let o = this; 51 51 52 52 const replaceBgImageTo2xBg = (element) => { 53 element.setAttribute('data-background-image', o. #replaceImgTo2Img(element.getAttribute('data-background-image')));54 } 53 element.setAttribute('data-background-image', o.__replaceImgTo2Img(element.getAttribute('data-background-image'))); 54 }; 55 55 56 56 document.querySelectorAll('.image2x[data-background-image]').forEach((element) => { … … 58 58 59 59 if (o.useIfFileExists) { 60 if (o. #urlExists(o.#replaceImgTo2Img(dataBackgroundImage.substring(5, (dataBackgroundImage.length - 2))))) {60 if (o.__urlExists(o.__replaceImgTo2Img(dataBackgroundImage.substring(5, (dataBackgroundImage.length - 2))))) { 61 61 replaceBgImageTo2xBg(element); 62 62 } … … 68 68 } 69 69 70 #image2x = () => {70 __image2x = () => { 71 71 const replaceSiblingsSourceElements = (currentElement) => { 72 72 currentElement.parentNode.childNodes.forEach((item) => { … … 77 77 return; 78 78 } 79 item.setAttribute('srcset', this. #replaceImgTo2Img(item.getAttribute('srcset')))79 item.setAttribute('srcset', this.__replaceImgTo2Img(item.getAttribute('srcset'))) 80 80 }); 81 } 81 }; 82 82 83 83 const pixelRatio = !!window.devicePixelRatio ? window.devicePixelRatio : 1; 84 84 85 85 if (pixelRatio > 1) { 86 this. #handleBgImageTo2xBg();86 this.__handleBgImageTo2xBg(); 87 87 88 88 const els = document.querySelectorAll('img.image2x'); … … 93 93 replaceSiblingsSourceElements(currentElement); 94 94 95 const src = this. #replaceImgTo2Img(currentElement.getAttribute('src'));96 if (this.useIfFileExists && !this. #urlExists(src)) {95 const src = this.__replaceImgTo2Img(currentElement.getAttribute('src')); 96 if (this.useIfFileExists && !this.__urlExists(src)) { 97 97 return; 98 98 } 99 99 100 100 currentElement.setAttribute('src', src); 101 currentElement.setAttribute('srcset', this. #replaceImgTo2Img(currentElement.getAttribute('srcset')));102 currentElement.setAttribute('data-srcset', this. #replaceImgTo2Img(currentElement.getAttribute('data-srcset')));103 currentElement.setAttribute('data-src', this. #replaceImgTo2Img(currentElement.getAttribute('data-src')));101 currentElement.setAttribute('srcset', this.__replaceImgTo2Img(currentElement.getAttribute('srcset'))); 102 currentElement.setAttribute('data-srcset', this.__replaceImgTo2Img(currentElement.getAttribute('data-srcset'))); 103 currentElement.setAttribute('data-src', this.__replaceImgTo2Img(currentElement.getAttribute('data-src'))); 104 104 } 105 105 } -
wp-lozad/trunk/lozad.php
r2755113 r2760300 4 4 Description: lazy loading of images by baroda algorithm 5 5 Author: Evgeniy Kozenok 6 Version: 1.6. 06 Version: 1.6.1 7 7 */ 8 8 -
wp-lozad/trunk/readme.txt
r2755113 r2760300 4 4 Requires at least: 5.0 5 5 Tested up to: 6.0 6 Stable tag: 1.6. 06 Stable tag: 1.6.1 7 7 License: GPL2 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 24 24 25 25 == Changelog == 26 = 1.6.1 = 27 * 2022-07-22: fix js private identifier in cache 28 26 29 = 1.6.0 = 27 30 * 2022-07-12: disable use jQuery. Wp 6.0 support
Note: See TracChangeset
for help on using the changeset viewer.