[Lazy-load][1] is a simple Drupal module which integrates [bLazy][2]
lazy-loading script via image field *display formatters* and *input-filters* for
inline images and iframes.
There is another contributed module utilizing its namesake, [Blazy][3]. Make
sure to check it out, especially if you need more advanced features and support
for many features out of the box.
This module started to fill-in the only area Blazy module lacks of;
**inline-images** and **inline-iframes**. Now, Lazy-load can also be enabled for
each image field as well.
You can use [Lazy-load][1] module tandem with [Blazy][3], though that is not a
requirement.
## Requirements
* **[Libraries API][5]** module (Drupal 7 only)
* **bLazy v1.8.2** script as a library item
## Installing Manually
- [Download bLazy][4] from https://github.com/dinbror/blazy
- Extract the downloaded file,
- rename *blazy-master* directory to *blazy*,
- copy the folder into one of the following places that *Libraries API*
module supports, `sites/all/libraries` (or site-specific libraries folder):
i.e.: `sites/all/libraries/blazy/blazy.min.js`
## Installing via Composer
- Run `composer require --prefer-dist composer/installers` to ensure that you
have the `composer/installers` package installed. This package facilitates the
installation of packages into directories other than `/vendor`
(e.g. `/libraries`) using Composer.
- If your `composer.json` doesn’t already have a definition for the libraries
path, define one similar to the one below, depending on your setup:
``` json
"extra": {
"installer-paths": {
"web/sites/all/libraries/{$name}": ["type:drupal-library"]
}
}
```
- Add following to the “repositories” section of `composer.json`:
``` json
"repositories": [
{
"type": "package",
"package": {
"name": "dinbror/blazy",
"version": "1.8.2",
"type": "drupal-library",
"extra": {
"installer-name": "blazy"
},
"source": {
"type": "git",
"url": "https://github.com/dinbror/blazy",
"reference": "1.8.2"
}
}
}
]
```
- Install the required **Blazy** library:
`composer require 'dinbror/blazy:1.8.2'`
- Install this module:
`composer require 'drupal/lazy:^1.0'`
## Usage
There are two options to set up for your site to lazy-load images. And both options share the same [settings](/admin/config/content/lazy).
1. Image fields
2. Inline images and Iframes managed in rich-text fields (ckeditor)
### Image Fields
1. Go to **Manage display** page of the entity type you want to enable lazy-loading. *i.e. Article*
2. Select the **display** you want the change. *i.e. Teaser*
3. Change the format from `Image` to
`Lazy-load image` to enable lazy-loading for the selected field.
The `Image` formatter settings for
_image style_ and _link image to_ should remain unchanged.
### Inline images and Iframes
1. **Configure** the [text format](/admin/config/content/formats) you want to enable lazy-loading. *i.e. Full HTML*
2. Check **Lazy-load images and IFRAMEs via bLazy** option to enable the filter, and save configuration.
3. Go to [Lazy-load settings](/admin/config/content/lazy).
4. Check the boxes for the inline elements to be lazy-loaded via filter `
` `