From d2e1e60ecc9c04f9e673470826f72efb1a0f636d Mon Sep 17 00:00:00 2001
From: Andrew Dolgov <noreply@fakecake.org>
Date: Fri, 7 Sep 2018 09:55:43 +0300
Subject: [PATCH] 1. per-feed option STRIP_IMAGES should now also affect other
 media tags 2. video/audio elements were not replaced with text links properly
 in low bandwidth mode

---
 include/functions.php | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/include/functions.php b/include/functions.php
index 453f329b4..be0d4e262 100755
--- a/include/functions.php
+++ b/include/functions.php
@@ -1682,22 +1682,32 @@
 						}
 					}
 				}
+			}
+
+			if ($entry->hasAttribute('src') &&
+					($owner && get_pref("STRIP_IMAGES", $owner)) || $force_remove_images || $_SESSION["bw_limit"]) {
+
+				$p = $doc->createElement('p');
+
+				$a = $doc->createElement('a');
+				$a->setAttribute('href', $entry->getAttribute('src'));
+
+				$a->appendChild(new DOMText($entry->getAttribute('src')));
+				$a->setAttribute('target', '_blank');
+				$a->setAttribute('rel', 'noopener noreferrer');
 
-				if (($owner && get_pref("STRIP_IMAGES", $owner)) ||
-					$force_remove_images || $_SESSION["bw_limit"]) {
+				$p->appendChild($a);
 
-					$p = $doc->createElement('p');
+				if ($entry->nodeName == 'source') {
 
-					$a = $doc->createElement('a');
-					$a->setAttribute('href', $entry->getAttribute('src'));
+					if ($entry->parentNode && $entry->parentNode->parentNode)
+						$entry->parentNode->parentNode->replaceChild($p, $entry->parentNode);
 
-					$a->appendChild(new DOMText($entry->getAttribute('src')));
-					$a->setAttribute('target', '_blank');
-					$a->setAttribute('rel', 'noopener noreferrer');
+				} else if ($entry->nodeName == 'img') {
 
-					$p->appendChild($a);
+					if ($entry->parentNode)
+						$entry->parentNode->replaceChild($p, $entry);
 
-					$entry->parentNode->replaceChild($p, $entry);
 				}
 			}
 
-- 
GitLab