-
Notifications
You must be signed in to change notification settings - Fork 8
/
readme.txt
664 lines (387 loc) · 21.4 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
=== Lazy Loader ===
Contributors: FlorianBrinkmann
Donate link: https://www.paypal.me/flobrinkmann
Tags: lazysizes, lazy loading, performance, images
Requires at least: 4.9.8
Tested up to: 6.5
Stable tag: 8.2.0
Requires PHP: 7.0
== Description ==
Lazy loading plugin that supports images, iFrames, video and audio elements and uses the lightweight lazysizes script. With manual modification of the markup it is also possible to lazy load background images, scripts, and styles.
Lazy loads (without the need of any manually modifications):
* Images inserted via `img` or `picture` in posts, pages, Custom Post Types, Text Widgets, …
* Post thumbnails.
* Inline background images.
* Or all images and other enabled media in the markup (that is not excluded or already has a lazy loading attribute), via the option to process the complete markup.
* iFrames.*
* Video elements.*
* Audio elements.*
\* *Can be enabled in the plugin options.*
**The plugin comes with the following options (under Settings › Media › Lazy Loader options):**
* Do not lazy load elements with specific CSS classes (you can use the class `skip-lazy` by default).
* Add filters that should be processed by Lazy Loader.
* Enable lazy loading for iFrames.
* Include the [lazysizes native loading plugin](https://github.com/aFarkas/lazysizes/tree/gh-pages/plugins/native-loading) that modifies images and iFrames to use the native lazy loading feature of browsers that already support it.
* Include the [lazysizes unveilhooks plugin](https://github.com/aFarkas/lazysizes/tree/gh-pages/plugins/unveilhooks) that adds support for more elements, for example, video and audio elements.*
* Enable lazy loading for the poster frame of video elements.
* Enable lazy loading for audio elements.
* Enable lazy loading for inline background images.
* Display a loading spinner.
* Disable the plugin on specific posts/pages (this shows a checkbox in the edit view of all public post types (except attachments) to disable lazy loading for an entire post).
* Process the complete markup of the site.
* A textarea to modify the default lazysizes config values.
\* The unveilhooks extension of lazysizes supports more than video and audio elements, but you need to manually modify the markup to use it for:
* Background images not inserted with inline styles.
* Scripts.
* Styles.
The plugin adds a `noscript` element as fallback for disabled JavaScript (can be disabled with the `lazy_loader_generate_noscript` filter).
You can disable lazy loading for elements with specific CSS classes by defining them via the plugin settings (*Settings* › *Media* › *Lazy Loader options*). Or use the `skip-lazy` class or the `data-skip-lazy` attribute. `skip-lazy` and `data-skip-lazy` also work on wrapper elements to exclude the wrapper and its children from being processed.
== Installation ==
* Install plugin.
* Activate it.
* You can find the plugin settings under *Settings* › *Media* › *Lazy Loader options*.
== Frequently Asked Questions ==
= Is there a way to manually call the plugin to modify markup of not-supported image functions? =
Yes. See the following example that would generate lazy-load-ready output for the result of the not-supported `wp_get_attachment_image()` function:
`
global $lazy_loader;
if ( isset( $lazy_loader ) && $lazy_loader instanceof FlorianBrinkmann\LazyLoadResponsiveImages\Plugin ) {
echo $lazy_loader->filter_markup( wp_get_attachment_image( 1261 ) );
}
`
To make it happen, you need to pass the markup that contains the image (or images) to `$lazy_loader->filter_markup()`. The `if` statement ensures that the Lazy Loader object is there and that it is an object of the correct class.
= How can I disable/modify the inline styles? =
**Important:** If you modify or remove the inline styles, also the style that shows the loading spinner is affected. So if you remove the styles or modify them without adding back the spinner styles, the spinner option will not work. [I created a Gist with the spinner styles – just add them to your modification to make it work](https://gist.github.com/florianbrinkmann/937495c7b41df3c1600ef7d9c6e95a9e).
To disable or modify the plugin’s inline styles (except the style that hides the `img.lazyload` elements when JS is disabled, so only the `noscript` version is displayed) you can use the `lazy_load_responsive_images_inline_styles` filter. For example, to remove the inline styles, use the following code:
`
add_filter( 'lazy_load_responsive_images_inline_styles', function () {
return '';
} );
`
If you want to modify it, you can do that like in the following code block (remember to include the opening and closing `style` tags for additions/replacements). The code modifies the duration of the fade-in-effect:
`
add_filter( 'lazy_load_responsive_images_inline_styles', function ( $default_styles ) {
$default_styles = sprintf(
'%s <style>:root {
--lazy-loader-animation-duration: 600ms;
}</style>',
$default_styles
);
return $default_styles;
} );
`
The CSS from the example are the default styles that are used by the plugin (without the loading spinner styles). The `display: block` for `.lazyload` is important for the aspectratio plugin option.
= How can I adjust the lazy load threshold/other lazysizes settings? =
There is a textarea in the plugin settings where you can insert custom settings for the lazysizes config.
== Changelog ==
= 8.2.0 – 14.04.2024 =
Tested with WordPress 6.5.
**Added**
* `lazy_loader_generate_noscript` filter to allow disabling of `noscript` element generation.
**Fixed**
- Updated `mastermind/html5` dependency to latest version, which fixes a PHP deprecation notice.
= 8.1.1 – 20.12.2022 =
Tested with WordPress 6.1.
**Fixed**
- Disable lazy loading in TranslatePress editor.
= 8.1.0 – 29.03.2021 =
**Added**
- Support for input elements of type `image`.
= 8.0.0 – 22.03.2021 =
**Removed**
- Processing of `wp_get_attachment_image`, introduced in 7.2.0. I just noticed that processing that filter by default may break cases where a wrapper element has the `skip-lazy` class to disable lazy loading for contained media elements. Lazy Loader is not aware of this when processing `wp_get_attachment_image`, because it cannot check the parent elements. If you want to process that filter with Lazy Loader, you can enter it in the settings field for additional filters.
= 7.2.3 – 17.03.2021 =
**Fixed**
- Stop processing embeds, because the lazysizes script is not loaded in the iframe and so the image in the embed can not be lazy loaded.
= 7.2.2 – 17.03.2021 =
**Fixed**
- Duplicate images in Ultimate Addons for Elementor widget – thanks @kaggdesign.
= 7.2.1 – 09.03.2021 =
**Fixed**
- Missing JS files in SVN repo.
= 7.2.0 – 08.03.2021 =
Tested with WordPress 5.7.
**Added**
* Process `wp_get_attachment_image` filter that was added in WordPress 5.6.
**Changed**
* Updated lazysizes and its plugins to 5.3.0.
**Fixed**
* Use same escaped version of SVG placeholder for `src` and `srcset` to fix a HTML validation error.
= 7.1.0 – 04.11.2020 =
**Changed**
* Add timestamp of file modification as version query string to Lazy Loader JS files instead of WordPress version.
**Fixed**
* Problem with Lazy Loader being active in Oxygen Builder editor.
= 7.0.0 – 10.08.2020 =
If you depend on the aspectratio script of lazysizes somehow that came with the plugin, this release has a breaking change: it removes the aspectratio option (and the script) because it uses inline SVGs as placeholders that have the same effect without needing the aspectratio script.
**Added**
* Disable core lazy load funcionality that comes with WP 5.5.
* `lazy_loader_attrs_to_strip_from_fallback_elem` filter that allows to provide an array of HTML attributes that should be stripped from the fallback element in the `noscript` element.
**Changed**
* If `width` and `height` attributes are present, the plugin uses an inline SVG to prevent content reflow – thanks to WP.org user lozula.
* Updated lazysizes and its extensions to version 5.2.2.
**Fixed**
* Problems with inline HTML comments in `script` tags. To fix that. inline script elements are no longer wrapped in HTML comments during markup processing to hide them from the parser. That was necessary for `DOMDocument()` but is not needed when using `Masterminds\HTML5()` (what Lazy Loader does).
**Removed**
* Aspectratio option. The change with the inline SVG makes that obsolete.
= 6.0.1 – 01.05.2020 =
**Changed**
* Added empty default value for the `$content` param of `Plugin\filter_markup()` method to prevent a fatal error that occurs sometimes when Lazy Loader is used with the Content Cards plugin.
* Check if there is already a script with the `lazysizes` handle registered and deregister it before enqueuing own version. Fixes issue with Avada theme that includes own version.
= 6.0.0 – 31.01.2020 =
**This release requires PHP 7**
**Added**
* Option to process the complete markup of a page instead of only parts of it via the filters (might take a little longer because the plugin needs to process more markup and, if your site contains HTML errors, lead to unwanted behavior, because the DOM Parser tries to correct that).
* Option to define additional filters for the plugin to process.
* Ignore patterns for `skip-lazy` class and `data-skip-lazy` attribute. Use them if you want Lazy Loader to ignore an element and its children. The `disable-lazyload` class and `data-no-lazyload` attribute will keep working for backwards compatibility. Adding the new class and attribute goes back to an initiative by Frank Goossens, developer of Autoptimize, who reached out to several devs of lazy loading plugins or plugins that also have a lazy loading feature to get a standard class and attribute across multiple plugins.
* Added donation link to plugin header.
**Changed**
* Updated required PHP version to 7.0.
* Security improvements via escaping and specifying allowed HTML in setting descriptions. Thanks @igmoweb
* Simplified `Plugin\add_noscript_element()` method. It just clones the source element now, instead of creating a new empty element and adding all attributes to it.
* Check markup for `[caption]` shortcode to prevent duplicated images in Elementor.
* Class properties are private now.
**Fixed**
* Error with invalid attribute names in `Plugin\add_noscript_element()` method.
= 5.1.2 – 12.11.2019 =
**Changed**
* Updated background image option text.
= 5.1.1 – 11.11.2019 =
**Changed**
* Updated readme.
= 5.1.0 – 11.11.2019 =
**Added**
* Lazy loading of background images.
* Lazy loading of videos with autoplay.
**Changed**
* Updated lazysizes and its extensions to 5.1.2.
* Updated tested up to version to 5.3.
**Fixed**
* Handle rest api requests with edit context as admin requests (thanks @websupporter!).
* Check if a post type supports `custom-fields` before loading block editor script.
= 5.0.0 – 28.06.2019 =
**Changed**
* Increased priority for the calls of `the_content` and `post_thumbnail_html` filters from `500` to `10001` to fix issues with the ShortPixel Image Optimizer. So if you use those filters and they need to run after the Lazy Loader, you need to increase the priority, too. This is the change that makes it a major version change.
**Fixed**
* Audio shortcode stripped from frontend with all following content.
= 4.1.0 – 31.05.2019 =
*Tested with WordPress 5.2*
**Added**
* Option for using the native loading extension from lazysizes.
* Textarea for custom lazysizes config values.
**Changed**
* Updated lazysizes to 5.1.0.
* Use CSS variable `var(--lazy-loader-animation-duration)` for duration of fade-in-effect after loading.
**Fixed**
* Do not load assets on pages where Lazy Loader is disabled.
* Preserve HTML and hex entities.
* Ignore inline scripts.
* Skip images that already have a `data-src` attribute.
* Checkbox for disabling Lazy Loader not showing for Custom Post Types added via a plugin.
= 4.0.1 – 20.02.2019 =
**Fixed**
* Removed debug code.
= 4.0.0 – 20.02.2019 =
*Tested with WordPress 5.1.*
**Changed**
* Renamed object in main plugin file from `$plugin` to `$lazy_loader` to make it accessible via the theme.
* Added an example for calling the `filter_markup()` method of the plugin from the theme to modify markup of not-supported image functions like `wp_get_attachment_image()`.
* Updated lazysizes to 4.1.6.
**Fixed**
* Wrong year in changelog for 3.5.0 and 3.5.1. Thanks @pra85!
* Correctly remove the plugin options from the options database table on uninstall.
= 3.5.1 – 28.01.2019 =
**Fixed**
* Wrong version number in plugin file.
= 3.5.0 – 28.01.2019 =
**Added**
* Option to disable lazy loading for specific posts/pages via a checkbox. The checkbox can be enabled via an option under *Settings* › *Media* › *Lazy Loader options*.
* Possibility to use the `disable-lazyload` class to disable the lazy loader for an element and its children.
**Changed**
* Updated lazysizes to 4.1.5.
* Added note about limited browser support to loading spinner option.
* Updated placeholder source to a more stable variation (thanks diegocanal for the hint).
**Fixed**
* Only use `save_html()` method if markup was modified.
* Keep `srcset` attribute with placeholder source to get valid HTML.
= 3.4.0 – 05.07.2018 =
**Added**
* Support for `picture` element.
**Fixed**
* Only use `data-sizes` attribute, if value is `auto`.
* Removed unnecessary check for `src` attribute in `modify_img_markup()`.
= 3.3.7 – 12.06.2018 =
**Fixed**
* Disable libxml errors.
= 3.3.6 – 11.06.2018 =
**Changed**
* Set a transparent data URI as img `src` instead of removing it to avoid page jumps that can happen during image loading (at least in Chrome).
* Updated lazysizes and plugins to 4.0.4.
**Fixed**
* Fix encoding issues with strings inside `script` elements.
= 3.3.5 – 14.04.2018 =
**Fixed**
* Not working with PHP 5.3.
= 3.3.4 – 05.04.2018 =
**Fixed**
* Use correct pattern for lazy loading of `video` and `audio` elements.
* Removed unnecessary `else` and a chunk of duplicate code (thanks mackzwellz).
* Issue with encoding of cyrillic characters.
**Changed**
* Updated lazysizes.js and the bundled plugins to 4.0.2.
* Run `post_thumbnail_html` filter later (priority 500, like for the `the_content` filter call, instead of 10), to fix a problem that appears when used with Responsify WP (thanks jgadbois).
* Moved the `add_noscript_element()` method call to the beginning of the `modify_*_markup` methods. With that, there is no need to remove the `lazyload` class in the `add_noscript_element()` method, because it was not added yet.
* Removed unnecessary `$new_iframe->setAttribute( 'src', $src )` call from the `add_noscript_element()`.
* Removed unnecessary `$dom->saveHTMLExact()` calls from the `modify_*_markup` methods.
* Use own `FlorianBrinkmann\LazyLoadResponsiveImages\Helpers()->save_html()` method for saving the HTML.
= 3.3.3 – 13.03.2018 =
**Fixed**
* Fix broken code blocks in readme file.
* Set `.lazyload` to `display: block` to make the aspectratio option work correctly again.
= 3.3.2 – 09.03.2018 =
**Fixed**
* Removed try to get width and height from images without `width` and `height` attr with `getimagesize` because it may cause a PHP warning.
= 3.3.1 – 09.03.2018 =
**Fixed**
* Added inline doc for `FlorianBrinkmann\LazyLoadResponsiveImages\Settings()->add_color_picker()`.
* Only load color picker styles and script if on media settings page.
= 3.3.0 – 09.03.2018 =
(there was also a new feature added in 3.2.9, but I forgot to increase the minor version number there…)
**Added**
* `lazy_load_responsive_images_inline_styles` filter for modifying the inline CSS (for modification, you also need to add the opening and closing `style` tags). If you use the spinner option and the filter, you need to add the spinner styles, because they are part of the filtered CSS ([Gist with the spinner styles used by default](https://gist.github.com/florianbrinkmann/937495c7b41df3c1600ef7d9c6e95a9e)).
* Option to display a loading spinner and define its color.
**Changed**
* Use style inside `noscript` element to hide `.lazyload` images if no JS instead of adding a `js` class via JS to the `html` element.
* Using `DOMXpath()->query()` to fetch the element nodes.
* Looping the nodes once inside `FlorianBrinkmann\LazyLoadResponsiveImages\Plugin()->filter_markup()` and no longer one time in each of the three element-specific methods.
**Fixed**
* Do not modify elements inside noscript elements.
* Doc fixes.
= 3.2.10 – 06.03.2018 =
**Fixed**
* Small error in the readme.
= 3.2.9 – 06.03.2018 =
**Added**
* Option to load the lazysizes aspectratio plugin. This plugin calculates the space that the images need before they are loaded. With that enabled, the lazy loading should also work for masonry grids without further markup modifications. Thanks to W.org user zitrusblau for the hint with the plugin.
= 3.2.8 – 27.02.2018 =
**Fixed**
* Correctly set `.lazyload` images to `display: none` if JS is disabled.
= 3.2.7 – 22.02.2018 =
**Added**
* Animated the opacity change when the images are loaded.
**Fixed**
* Duplicated images if, for example, the `the_content` filter is run multiple times.
* Small doc fix.
= 3.2.6 – 30.11.2017 =
**Changed**
* Automatically load unveilhooks extension if audio or video option is enabled, regardless of the option to load the unveilhooks plugin is enabled or not.
* Updated *Tested up to* version to 4.9.1.
= 3.2.5 – 27.11.2017 =
**Fixed**
* Wrong path to plugin options in the readme.txt.
= 3.2.4 – 25.11.2017 =
**Fixed**
* Fatal error due case mismatch in referencing the SmartDOMDocument class – sorry for that!
= 3.2.3 – 25.11.2017 =
**Fixed**
* Line break issues with the readme for W.org.
= 3.2.2 – 25.11.2017 =
**Fixed**
* Problem with duplicated images in HTML widget.
= 3.2.1 – 25.11.2017 =
**Fixed**
* Load minified version of lazysizes unveilhooks plugin.
= 3.2.0 – 25.11.2017 =
**Added**
* Option to automatically lazy load iFrames.
* Option to automatically lazy load videos.
* Option to automatically lazy load audio.
* Option to additionally load the unveilhooks plugin of lazysizes. This enables lazy loading of audio, video, scripts, and more.
* Support for images inside the text and HTML widget. Does not work for galleries in the widgets.
* Support for Gravatars.
* Autoloading of classes with Composer.
**Changed**
* Changed plugin name to »Lazy Loader«.
* Moved settings to the media settings page and removed the customizer section.
* PHP comment style for inline comments.
* Renamed the class files in `src`.
**Fixed**
* Small doc errors.
= 3.1.13 – 08.11.2017 =
**Changed**
* Updated lazysizes to 4.0.1.
* Updated »Tested up to« version to 4.9 in readme.
= 3.1.12 – 22.09.2017 =
**Fixed**
* Added back the support for `data-no-lazyload` attr to disable lazy loading for specific images (was removed in 3.1.0 without keeping backwards compatibility in mind, sorry).
= 3.1.11 – 19.09.2017 =
**Changed**
* Added details to the readme, what images are lazy loaded.
**Fixed**
* Now also adds a `noscript` element for gallery images.
**Removed**
* No lazy loading for images that are added via `wp_get_attachment_image()`, because for those images cannot be added a `noscript` fallback.
= 3.1.10 – 17.09.2017 =
**Fixed**
* is_admin_request() check does not work for subdirectory installs.
= 3.1.9 – 25.08.2017 =
**Fixed**
* Product image appears twice in WooCommerce cart.
= 3.1.8 – 10.08.2017 =
**Fixed**
* Bump »Requires at least« to 4.5 because using wp_add_inline_script() since a few versions.
= 3.1.7 – 10.08.2017 =
**Fixed**
* Use saveHTMLExact() method from SmartDomDocument to prevent doctype, html and body element to be added to the content.
= 3.1.6 – 07.08.2017 =
**Fixed**
* Disable lazy loading for AMP pages which are generated by the »AMP« plugin by Automattic.
= 3.1.5 – 20.07.2017 =
**Fixed**
* Further issues with PHP 5.3.
* Issue with lazy loaded post thumbnail in the backend.
= 3.1.4 – 14.07.2017 =
**Fixed**
* Replaced [] array syntax with traditional one, so it works with PHP 5.3 again.
= 3.1.3 – 07.07.2017 =
**Fixed**
* Wrong check for js class, which causes hidden images if nothing else added a js class…
= 3.1.2 =
**Fixed**
* Capital P for one »WordPress« in readme and one in plugin description.
= 3.1.1 =
**Changed**
* Added option to disable lazy loading for specific classes to readme.
**Fixed**
* Correct text domain.
= 3.1.0 =
**Added**
* Customizer option to specify image class names to disable lazy loading for those.
**Changed**
* Using semver.
* Make it work with AJAX requests (thanks to zitrusblau).
* Using classes and namespaces.
* Using SmartDomDocument class.
* Updated plugin URL.
* Doc improvements.
= 3.0 =
* Updated lazysizes to 3.0.0 (Thanks FlorianBrinkmann)
* Plugin version reflects version of lazysizes.
= 1.0.9 =
* Allow opting out of lazy load with "data-no-lazyload" attribute (Thanx wheresrhys)
= 1.0.8 =
* Bugfix for missing images if javascript is disabled.
= 1.0.7 =
* Added a check to prevent the plugin being applied multiple times on the same image. (Thanx to saxonycreative)
= 1.0.6 =
* added missing src attribute. Older browsers like the PS4 browser now work again.
= 1.0.5 =
* now prevents lazy loading in atom feeds and the WordPress backend.
= 1.0.4 =
* Changed description to reflect the compatibility with WordPress 4.4 core responsive images.
* Removed skipping of the first image in the post.
* Adds css class "js" to body tag for better compatibility.
= 1.0.3 =
* fixed path to js and css.
= 1.0.2 =
* typo in WordPress usernames.