Dieses Plugin ist nicht mit den jüngsten 3 Hauptversionen von WordPress getestet worden. Es wird möglicherweise nicht mehr gewartet oder unterstützt und kann Kompatibilitätsprobleme haben, wenn es mit neueren Versionen von WordPress verwendet wird.

Lazy Loader

Beschreibung

Lazy-Loading-Plugin das Bilder, iFrames, video- und audio-Elemente unterstützt und das schlanke lazysizes-Skript nutzt. Mit manuellen Anpassungen des Markups können auch Hintergrundbilder, Skripte und Stylesheets nachgeladen werden.

Unterstützt automatisches Lazy Loading für:

  • Images inserted via img or picture in posts, pages, Custom Post Types, Text Widgets, …
  • Beitragsbilder.
  • 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-Elemente.*
  • audio-Elemente.*

* Kann in den Plugin-Optionen aktiviert werden.

Das Plugin kommt mit den folgenden Optionen (unter Einstellungen › Medien › Lazy-Loader-Optionen):

  • 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.
  • Lazy Loading für iFrames aktivieren.
  • Include the lazysizes native loading plugin that modifies images and iFrames to use the native lazy loading feature of browsers that already support it.
  • Include the lazysizes unveilhooks plugin that adds support for more elements, for example, video and audio elements.*
  • Lazy Loading für das Vorschaubild von video-Elementen aktivieren.
  • Lazy Loading für audio-Elemente aktivieren.
  • 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.
  • Ein Textfeld, um die Standard-Werte der lazysizes-Konfiguration zu verändern.

* Die unveilhooks-Extension von lazysizes unterstützt mehr als video- und audio-Elemente, aber dafür musst du das Markup selbst anpassen:

  • Background images not inserted with inline styles.
  • Skripte.
  • Stylesheets.

Das Plugin fügt ein noscript-Element als Fallback für deaktiviertes JavaScript ein.

You can disable lazy loading for elements with specific CSS classes by defining them via the plugin settings (SettingsMediaLazy 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

  • Installiere das Plugin
  • Aktiviere es
  • You can find the plugin settings under SettingsMediaLazy Loader options.

FAQ

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.

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.

Rezensionen

1. Juni 2022
Quite strange matter - tested on WP 5.9.3, and 6.0 - when a gallery has JPEG thumbnails then native lazy loading works as suspected, but when a gallery is built with WEBP thumbnails it does NOT!? despite loading="lazy" attribute at every IMG. Thank you!!
2. März 2022 1 Antwort
Great, you can just exclude images etc. I need it for that.
8. Dezember 2021 1 Antwort
This is an incredible plugin, it works great on one of my websites but unfortunately, it doesn't work at all on my other staging website, don't know if I am doing something wrong.
23. September 2021 1 Antwort
Works great. Improved my site and PWA performance and load times. Thank you!
Alle 48 Rezensionen lesen

Mitwirkende & Entwickler

„Lazy Loader“ ist Open-Source-Software. Folgende Menschen haben an diesem Plugin mitgewirkt:

Mitwirkende

„Lazy Loader“ wurde in 1 Sprache übersetzt. Danke an die Übersetzerinnen und Übersetzer für ihre Mitwirkung.

Übersetze „Lazy Loader“ in deine Sprache.

Interessiert an der Entwicklung?

Durchstöbere den Code, sieh dir das SVN Repository an oder abonniere das Entwicklungsprotokoll per RSS.

Änderungsprotokoll

8.1.1 – 20.12.2022

Tested with WordPress 6.1.

Fixed

  • Disable lazy loading in TranslatePress editor.

8.1.0 – 29.03.2021

Hinzugefügt

  • Support for input elements of type image.

8.0.0 – 22.03.2021

Entfernt

  • 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.

Hinzugefügt

  • Process wp_get_attachment_image filter that was added in WordPress 5.6.

Geändert

  • 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

Geändert

  • 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.

Hinzugefügt

  • 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.

Geändert

  • 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).

Entfernt

  • Aspectratio option. The change with the inline SVG makes that obsolete.

6.0.1 – 01.05.2020

Geändert

  • 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

Hinzugefügt

  • 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.

Geändert

  • 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

Geändert

  • Updated background image option text.

5.1.1 – 11.11.2019

Geändert

  • Updated readme.

5.1.0 – 11.11.2019

Hinzugefügt

  • Lazy loading of background images.
  • Lazy loading of videos with autoplay.

Geändert

  • 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

Geändert

  • 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

Hinzugefügt

  • Option for using the native loading extension from lazysizes.
  • Textarea for custom lazysizes config values.

Geändert

  • 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

Hinzugefügt

  • Option to disable lazy loading for specific posts/pages via a checkbox. The checkbox can be enabled via an option under SettingsMediaLazy Loader options.
  • Possibility to use the disable-lazyload class to disable the lazy loader for an element and its children.

Geändert

  • 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

Hinzugefügt

  • 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

Geändert

  • 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.

Geändert

  • 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…)

Hinzugefügt

  • 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).
  • Option to display a loading spinner and define its color.

Geändert

  • 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

  • Kleiner Fehler in der Readme.

3.2.9 – 06.03.2018

Hinzugefügt

  • Option um das lazysizes-aspectratio-Plugin einzufügen. Das Plugin berechnet den benötigten Platz für die Bilder bevor sie geladen werden. Damit sollte das Lazy Loading auch für Masonry-Grids funktionieren, ohne dass weitere Anpassungen am Markup notwendig sind. Danke an zitrusblau für den Hinweis mit dem Plugin.

3.2.8 – 27.02.2018

Fixed

  • .lazyload-Bilder korrekt auf display: none setzen, wenn JS nicht aktiviert ist.

3.2.7 – 22.02.2018

Hinzugefügt

  • Die Änderung der Transparenz nach dem Laden der Bilder ist jetzt animiert.

Fixed

  • In bestimmten Fällen doppelte Bilder, zum Beispiel wenn der the_content-Filter mehrfach läuft.
  • Kleiner Doc-Fix.

3.2.6 – 30.11.2017

Geändert

  • Die unveilhooks-Erweiterung automatisch laden, wenn die Option für audio- oder video-Elemente aktiv ist, auch wenn die Option zum Laden des unveilhooks-Plugins selbst nicht aktiv sein sollte.
  • Tested up to-Version auf 4.9.1 geändert.

3.2.5 – 27.11.2017

Fixed

  • Falscher Pfad zu den Plugin-Optionen in der readme.txt.

3.2.4 – 25.11.2017

Fixed

  • Fataler Fehler durch falsche Groß- und Kleinschreibung des Klassennamens SmartDOMDocument bei der Referenzierung – sorry dafür!

3.2.3 – 25.11.2017

Fixed

  • Probleme mit Zeilenumbrüchen in der Readme für W.org.

3.2.2 – 25.11.2017

Fixed

  • Problem mit doppelten Bildern im HTML-Widget.

3.2.1 – 25.11.2017

Fixed

  • Minifizierte Version des unveilhooks-Plugins von lazysizes laden.

3.2.0 – 25.11.2017

Hinzugefügt

  • Option zum automatischen Lazy Loading von iFrames.
  • Option zum automatischen Lazy Loading von video-Elementen.
  • Option zum automatischen Lazy Loading von audio-Elementen.
  • Option, um zusätzlich das unveilhooks-Plugin von lazysizes zu laden. Damit ist Lazy Loading von audio- und video-Elementen, Skripten und mehr möglich.
  • Unterstützung für Bilder in Text- und HTML-Widgets. Funktioniert nicht für Galerien in den Widgets.
  • Unterstützung für Gravatare.
  • Autoloading von Klassen mit Autoloader von Composer.

Geändert

  • Plugin-Namen in »Lazy Loader« geändert.
  • Einstellungen zur Medien-Einstellungsseite verschoben und die Customizer-Section entfernt.
  • PHP-Kommentarstil für Inline-Kommentare.
  • Klassendateien in src umbenannt.

Fixed

  • Kleine Dokumentations-Fehler.

3.1.13 – 08.11.2017

Geändert

  • lazysizes auf 4.0.1 aktualisiert.
  • »Tested up to«-Version auf 4.9 angehoben.

3.1.12 – 22.09.2017

Fixed

  • Unterstützung des data-no-lazyload-Attributs zur Deaktivierung von Lazy Loading wiederhergestellt (wurde in 3.1.0 entfernt, ohne an die Rückwärtskompatibilität zu denken, sorry).

3.1.11 – 19.09.2017

Geändert

  • Details dazu in die Readme eingefügt, welche Bilder das Plugin lazy-loaded.

Fixed

  • Jetzt auch mit noscript-Element für Galerie-Bilder.

Entfernt

  • Kein Lazy-Loading für Bilder, die über wp_get_attachment_image() eingefügt wurden, da für diese Bilder kein noscript-Fallback bereitgestellt werden kann.

3.1.10 – 17.09.2017

Fixed

  • is_admin_request()-Prüfung funktioniert nicht für Unterverzeichnis-Installationen.

3.1.9 – 25.08.2017

Fixed

  • Produktbilder erscheinen in WooCommerce-Warenkorb zweimal.

3.1.8 – 10.08.2017

Fixed

  • »Requires at least« auf 4.5 gestellt, da seit einigen Versionen wp_add_inline_script() genutzt wird.

3.1.7 – 10.08.2017

Fixed

  • saveHTMLExact()-Methode von SmartDomDocument nutzen um zu verhindern, dass doctype, html- und body-Elemente zum Inhalt hinzugefügt werden.

3.1.6 – 07.08.2017

Fixed

  • Lazy Loading für AMP-Seiten deaktivieren, die vom »AMP«-Plugin von Automattic erstellt werden.

3.1.5 – 20.07.2017

Fixed

  • Weitere Proleme mit PHP 5.3.
  • Problem mit Beitragsbildern im Backend, die fälschlicherweise auch vom Plugin behandelt wurden.

3.1.4 – 14.07.2017

Fixed

  • []-Array-Syntax mit array() ersetzt, damit es auch wieder auf PHP 5.3 funktioniert.

3.1.3 – 07.07.2017

Fixed

  • Falscher Check auf js-Klasse führt zu versteckten Bildern, wenn nichts anderes diese Klasse hinzufügt.

3.1.2

Fixed

  • Großes P für ein »WordPress« in der Readme und eins in der Plugin-Beschreibung.

3.1.1

Geändert

  • Deaktivierungs-Möglichkeit zu Readme hinzugefügt.

Fixed

  • Korrekte Text-Domain.

3.1.0

Hinzugefügt

  • Customizer-Option um Bilder via Klassenname vom Lazy Loading auszuschließen.

Geändert

  • Nutzung von semver.
  • Funktioniert nun auch mit AJAX-Requests (Dank an zitrusblau).
  • Klassen und Namespaces.
  • Verwendung der SmartDomDocument-Klasse.
  • Plugin-URL aktualisiert.
  • Verbesserungen der Dokumentation.

3.0

  • lazysizes auf 3.0.0 aktualisiert (Dank an FlorianBrinkmann)
  • Plugin-Version spiegelt die lazysizes-Version wider.

1.0.9

  • Erlaubt es, Bilder mit dem »data-no-lazyload«-Attribut vom Lazy Loading auszuschließen (Dank an wheresrhys)

1.0.8

  • Bugfix für fehlende Bilder bei deaktiviertem JavaScript

1.0.7

  • Check hinzugefügt, damit das Plugin nicht mehrfach auf dasselbe Bild angewendet wird (Dank an saxonycreative)

1.0.6

  • Fehlendes src-Attribut eingefügt. Ältere Browser, wie der PS4-Browser, funktionieren jetzt wieder.

1.0.5

  • Verhindert Lazy Loading in Feeds und dem WordPress-Backend.

1.0.4

  • Beschreibung wurde geändert, um die Kompatibilität mit dem Responsive-Images-Feature aus WordPress 4.4 zu kennzeichnen.
  • Skippen des ersten Bildes im Post entfernt.
  • js-Klasse wird für bessere Kompatibilität zu body-Tag hinzugefügt.

1.0.3

  • Pfad zu CSS und JS behoben.

1.0.2

  • Typo in WordPress-Benutzernamen.