mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 12:20:44 +02:00
Lazy loading added to bbcode images and avatar images by default.
This commit is contained in:
@@ -80,6 +80,11 @@
|
|||||||
unset($imgParms['figcaption']);
|
unset($imgParms['figcaption']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(empty($imgParms['loading']))
|
||||||
|
{
|
||||||
|
$imgParms['loading'] = 'lazy';
|
||||||
|
}
|
||||||
|
|
||||||
$resizeWidth = e107::getBB()->resizeWidth();
|
$resizeWidth = e107::getBB()->resizeWidth();
|
||||||
|
|
||||||
$w = !empty($imgParms['width']) ? (int) $imgParms['width'] : vartrue($resizeWidth, 0);
|
$w = !empty($imgParms['width']) ? (int) $imgParms['width'] : vartrue($resizeWidth, 0);
|
||||||
|
@@ -4109,9 +4109,10 @@ class e_parse
|
|||||||
|
|
||||||
$class = !empty($options['class']) ? $options['class'] : $shape . ' user-avatar';
|
$class = !empty($options['class']) ? $options['class'] : $shape . ' user-avatar';
|
||||||
$style = !empty($options['style']) ? " style='" . $options['style'] . "'" : '';
|
$style = !empty($options['style']) ? " style='" . $options['style'] . "'" : '';
|
||||||
|
$loading = !empty($options['loading']) ? " loading='".$options['loading']."'" : " loading='lazy'"; // default to lazy.
|
||||||
|
|
||||||
$text = $linkStart;
|
$text = $linkStart;
|
||||||
$text .= '<img ' . $id . "class='" . $class . $classOnline . "' alt=\"" . $title . "\" src='" . $url . "' width='" . $width . "' " . $heightInsert . $style . ' />';
|
$text .= '<img ' . $id . "class='" . $class . $classOnline . "' alt=\"" . $title . "\" src='" . $url . "' width='" . $width . "' " . $heightInsert . $style . $loading . ' />';
|
||||||
$text .= $linkEnd;
|
$text .= $linkEnd;
|
||||||
|
|
||||||
// return $url;
|
// return $url;
|
||||||
|
@@ -42,23 +42,23 @@
|
|||||||
array(
|
array(
|
||||||
'codetext' => '{e_MEDIA_IMAGE}2020-12/5.sm.webp',
|
'codetext' => '{e_MEDIA_IMAGE}2020-12/5.sm.webp',
|
||||||
'parm' => '',
|
'parm' => '',
|
||||||
'expected' => '<img class="img-rounded rounded bbcode bbcode-img" src="thumb.php?src=e_MEDIA_IMAGE%2F2020-12%2F5.sm.webp&w=0&h=0" alt="5.sm.webp" />'
|
'expected' => '<img class="img-rounded rounded bbcode bbcode-img" src="thumb.php?src=e_MEDIA_IMAGE%2F2020-12%2F5.sm.webp&w=0&h=0" alt="5.sm.webp" loading="lazy" />'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'codetext' => '{e_MEDIA}images/2020-12/horse.jpg',
|
'codetext' => '{e_MEDIA}images/2020-12/horse.jpg',
|
||||||
'parm' => 'width=300',
|
'parm' => 'width=300',
|
||||||
'expected' => '<img class="img-rounded rounded bbcode bbcode-img" src="thumb.php?src=e_MEDIA_IMAGE%2F2020-12%2Fhorse.jpg&w=300&h=0" alt="Horse" srcset="thumb.php?src=e_MEDIA_IMAGE%2F2020-12%2Fhorse.jpg&w=600&h=0 2x" width="300" title="Horse" />'
|
'expected' => '<img class="img-rounded rounded bbcode bbcode-img" src="thumb.php?src=e_MEDIA_IMAGE%2F2020-12%2Fhorse.jpg&w=300&h=0" alt="Horse" srcset="thumb.php?src=e_MEDIA_IMAGE%2F2020-12%2Fhorse.jpg&w=600&h=0 2x" width="300" loading="lazy" title="Horse" />'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'codetext' => '{e_MEDIA_IMAGE}2020-12/horse.jpg',
|
'codetext' => '{e_MEDIA_IMAGE}2020-12/horse.jpg',
|
||||||
'parm' => 'width=300',
|
'parm' => 'width=300',
|
||||||
'expected' => '<img class="img-rounded rounded bbcode bbcode-img" src="thumb.php?src=e_MEDIA_IMAGE%2F2020-12%2Fhorse.jpg&w=300&h=0" alt="Horse" srcset="thumb.php?src=e_MEDIA_IMAGE%2F2020-12%2Fhorse.jpg&w=600&h=0 2x" width="300" title="Horse" />'
|
'expected' => '<img class="img-rounded rounded bbcode bbcode-img" src="thumb.php?src=e_MEDIA_IMAGE%2F2020-12%2Fhorse.jpg&w=300&h=0" alt="Horse" srcset="thumb.php?src=e_MEDIA_IMAGE%2F2020-12%2Fhorse.jpg&w=600&h=0 2x" width="300" loading="lazy" title="Horse" />'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'codetext' => '{e_THEME}voux/install/gasmask.jpg',
|
'codetext' => '{e_THEME}voux/install/gasmask.jpg',
|
||||||
'parm' => 'width=300&alt=Custom',
|
'parm' => 'width=300&alt=Custom&loading=auto',
|
||||||
'expected' => "<figure>
|
'expected' => "<figure>
|
||||||
<img class=\"img-rounded rounded bbcode bbcode-img\" src=\"thumb.php?src=e_THEME%2Fvoux%2Finstall%2Fgasmask.jpg&w=300&h=0\" alt=\"Custom\" srcset=\"thumb.php?src=e_THEME%2Fvoux%2Finstall%2Fgasmask.jpg&w=600&h=0 2x\" width=\"300\" title=\"Custom\" /><figcaption>Custom</figcaption>
|
<img class=\"img-rounded rounded bbcode bbcode-img\" src=\"thumb.php?src=e_THEME%2Fvoux%2Finstall%2Fgasmask.jpg&w=300&h=0\" alt=\"Custom\" srcset=\"thumb.php?src=e_THEME%2Fvoux%2Finstall%2Fgasmask.jpg&w=600&h=0 2x\" width=\"300\" loading=\"auto\" title=\"Custom\" /><figcaption>Custom</figcaption>
|
||||||
</figure>"
|
</figure>"
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user