├── screen.png ├── registration.php ├── etc └── module.xml ├── composer.json ├── README.md └── view └── adminhtml ├── pagebuilder └── content_type │ └── image.xml └── ui_component └── pagebuilder_image_form.xml /screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/develodesign/magento-module-pagebuilder-lazyload-images/HEAD/screen.png -------------------------------------------------------------------------------- /registration.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "develodesign/magento-module-pagebuilder-lazyload-images", 3 | "description": "Uses the modern browser loading=\"lazy\" attribute on images added via page builder. Can be turned on and off per image as needed.", 4 | "type": "magento2-module", 5 | "version": "1.0", 6 | "license": "GPL-3.0", 7 | "authors": [ 8 | { 9 | "name": "Luke Collymore", 10 | "email": "luke@develodesign.co.uk" 11 | } 12 | ], 13 | "autoload": { 14 | "files": [ 15 | "registration.php" 16 | ], 17 | "psr-4": { 18 | "Develodesign\\PagebuilderLazyloadImages\\": "" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Magento 2 Module for adding loading="lazy" to page builder images 2 | 3 | - [Main Functionalities](#markdown-header-main-functionalities) 4 | - [Installation](#markdown-header-installation) 5 | - [Configuration](#markdown-header-configuration) 6 | 7 | 8 | ## Main Functionalities 9 | Uses the modern browser loading="lazy" attribute on images added via page builder. Can be turned on and off per image as needed. 10 | 11 | 12 | * **Do not turn on for images loaded above the fold, this causes unnecessary layout shift (CLS).** 13 | 14 | 15 | ### Composer 16 | 17 | ``` 18 | composer require develodesign/magento-module-pagebuilder-lazyload-images 19 | 20 | bin/magento module:enable Develodesign_PagebuilderLazyLoadImages 21 | bin/magento setup:upgrade 22 | bin/magento cache:flush 23 | ``` 24 | 25 | ### Zip file 26 | 27 | - Unzip the zip file in `app/code/Develodesign/PagebuilderLazyloadImages` 28 | - Enable the module by running `php bin/magento module:enable Develodesign_PagebuilderLazyloadImages` 29 | - Apply database updates by running `php bin/magento setup:upgrade`\* 30 | - Flush the cache by running `php bin/magento cache:flush` 31 | 32 | ## Installation 33 | * = in production please use the option `--keep-generated` 34 | 35 | ![This is an image](https://raw.githubusercontent.com/develodesign/magento-module-pagebuilder-lazyload-images/main/screen.png) 36 | -------------------------------------------------------------------------------- /view/adminhtml/pagebuilder/content_type/image.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 | 20 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /view/adminhtml/ui_component/pagebuilder_image_form.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 |
9 |
10 | 11 | 12 | 13 | lazy 14 | 15 | 16 | 17 | boolean 18 | 19 | loading_mobile 20 | 21 | 22 | 23 | 24 | 25 | 26 | lazy 27 | 28 | toggle 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | lazy 37 | 38 | 39 | 40 | boolean 41 | 42 | loading 43 | 44 | 45 | 46 | 47 | 48 | 49 | lazy 50 | 51 | toggle 52 | 53 | 54 | 55 | 56 |
57 |
58 | --------------------------------------------------------------------------------