aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Inverle <inverle@proton.me> 2025-06-03 00:14:50 +0200
committerGravatar GitHub <noreply@github.com> 2025-06-03 00:14:50 +0200
commitdd5ea7ab4ef5fd7553fef15ebbb13504d0d881ad (patch)
tree45d50e82468614f2236f49e0b3dbbc0a98ed467e /lib
parent58a264db4007971b36c6b058287c9d43e9c8443a (diff)
Include remaining tags/attributes for lazy loading (#7636)
* Include remaining tags/attributes for lazy loading * Suggested change
Diffstat (limited to 'lib')
-rw-r--r--lib/lib_rss.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index bcd8e51b0..f76ac49e9 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -368,7 +368,11 @@ function customSimplePie(array $attributes = [], array $curl_options = []): \Sim
'iframe' => 'src',
'img' => [
'longdesc',
- 'src'
+ 'src',
+ ],
+ 'image' => [
+ 'longdesc',
+ 'src',
],
'input' => 'src',
'ins' => 'cite',
@@ -632,16 +636,20 @@ function validateEmailAddress(string $email): bool {
/**
* Add support of image lazy loading
- * Move content from src attribute to data-original
+ * Move content from src/poster attribute to data-original
* @param string $content is the text we want to parse
*/
function lazyimg(string $content): string {
return preg_replace([
- '/<((?:img|iframe)[^>]+?)src="([^"]+)"([^>]*)>/i',
- "/<((?:img|iframe)[^>]+?)src='([^']+)'([^>]*)>/i",
+ '/<((?:img|image|iframe)[^>]+?)src="([^"]+)"([^>]*)>/i',
+ "/<((?:img|image|iframe)[^>]+?)src='([^']+)'([^>]*)>/i",
+ '/<((?:video)[^>]+?)poster="([^"]+)"([^>]*)>/i',
+ "/<((?:video)[^>]+?)poster='([^']+)'([^>]*)>/i",
], [
'<$1src="' . Minz_Url::display('/themes/icons/grey.gif') . '" data-original="$2"$3>',
"<$1src='" . Minz_Url::display('/themes/icons/grey.gif') . "' data-original='$2'$3>",
+ '<$1poster="' . Minz_Url::display('/themes/icons/grey.gif') . '" data-original="$2"$3>',
+ "<$1poster='" . Minz_Url::display('/themes/icons/grey.gif') . "' data-original='$2'$3>",
],
$content
) ?? '';