Browse Source

Lazy-load `<track src>` (#7997)

Follow-up of #7636

I found it's the only missing element that needs to be lazy loaded by putting HTML of https://github.com/cure53/HTTPLeaks/blob/main/leak.html into a feed
Inverle 6 months ago
parent
commit
067479a9f1
2 changed files with 3 additions and 3 deletions
  1. 2 2
      lib/lib_rss.php
  2. 1 1
      p/scripts/main.js

+ 2 - 2
lib/lib_rss.php

@@ -731,8 +731,8 @@ function validateEmailAddress(string $email): bool {
  */
 function lazyimg(string $content): string {
 	return preg_replace([
-			'/<((?:img|image|iframe)[^>]+?)src="([^"]+)"([^>]*)>/i',
-			"/<((?:img|image|iframe)[^>]+?)src='([^']+)'([^>]*)>/i",
+			'/<((?:img|image|iframe|track)[^>]+?)src="([^"]+)"([^>]*)>/i',
+			"/<((?:img|image|iframe|track)[^>]+?)src='([^']+)'([^>]*)>/i",
 			'/<((?:video)[^>]+?)poster="([^"]+)"([^>]*)>/i',
 			"/<((?:video)[^>]+?)poster='([^']+)'([^>]*)>/i",
 		], [

+ 1 - 1
p/scripts/main.js

@@ -441,7 +441,7 @@ const freshrssOpenArticleEvent = document.createEvent('Event');
 freshrssOpenArticleEvent.initEvent('freshrss:openArticle', true, true);
 
 function loadLazyImages(rootElement) {
-	rootElement.querySelectorAll('img[data-original], iframe[data-original], video[data-original]').forEach(function (el) {
+	rootElement.querySelectorAll('img[data-original], iframe[data-original], video[data-original], track[data-original]').forEach(function (el) {
 		if (el.tagName === 'VIDEO') {
 			el.poster = el.getAttribute('data-original');
 		} else {