Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Add native browser lazy loading for images
This change adds the browser-native lazy loading option "loading" HTML attribute for images. See https://addyosmani.com/blog/lazy-loading/ for more details. Resolves: #90426 Releases: master Change-Id: I5c457ed5b72ef81622e5135f182d7b10ededd4df Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63317 Tested-by: Georg Ringer <georg.ringer@gmail.com> Tested-by: Christian Eßl <indy.essl@gmail.com> Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Georg Ringer <georg.ringer@gmail.com> Reviewed-by: Christian Eßl <indy.essl@gmail.com> Reviewed-by: Benni Mack <benni@typo3.org>
- Loading branch information
Showing
6 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...mentation/Changelog/master/Feature-90426-Browser-nativeLazyLoadingForImages.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
.. include:: ../../Includes.txt | ||
|
||
======================================================== | ||
Feature: #90426 - Browser-native lazy loading for images | ||
======================================================== | ||
|
||
See :issue:`90426` | ||
|
||
Description | ||
=========== | ||
|
||
TYPO3 now supports the browser-native `loading` HTML attribute in :html:`<img>` tags. | ||
|
||
It is set to "lazy" by default for all images within Content Elements rendered | ||
with Fluid Styled Content. Supported browsers then choose to load these | ||
images at a later point when the image is within the browsers' Viewport. | ||
|
||
The configuration option is available via TypoScript constants and | ||
can be easily adjusted via the TypoScript Constant Editor in the Template module. | ||
|
||
Please note that not all browsers support this option yet, but adding | ||
this property will just be skipped for unsupported browsers. | ||
|
||
|
||
Impact | ||
====== | ||
|
||
TYPO3 Frontend now renders images in content elements with the "loading=lazy" | ||
attribute by default when using TYPO3's templates from Fluid Styled Content. | ||
|
||
Using the TypoScript constant `styles.content.image.lazyLoading`, | ||
the behavior can be modified generally to be either set to `eager`, | ||
`auto` or to an empty value, removing the property directly. | ||
|
||
The Fluid ImageViewHelper has the possibility to set this option | ||
via `<f:image src="{fileObject}" treatIdAsReference="true" loading="lazy">` | ||
to hint the browser on how the prioritization of image loading should be used. | ||
|
||
.. index:: Frontend, ext:fluid_styled_content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
typo3/sysext/fluid_styled_content/Resources/Private/Partials/Media/Rendering/Image.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true"> | ||
<f:media class="image-embed-item" file="{file}" width="{dimensions.width}" height="{dimensions.height}" alt="{file.alternative}" title="{file.title}" /> | ||
<f:media class="image-embed-item" file="{file}" width="{dimensions.width}" height="{dimensions.height}" alt="{file.alternative}" title="{file.title}" loading="{settings.media.lazyLoading}" /> | ||
</html> |