]> git.wh0rd.org - tt-rss.git/commitdiff
1. per-feed option STRIP_IMAGES should now also affect other media tags
authorAndrew Dolgov <noreply@fakecake.org>
Fri, 7 Sep 2018 06:55:43 +0000 (09:55 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Fri, 7 Sep 2018 06:55:43 +0000 (09:55 +0300)
2. video/audio elements were not replaced with text links properly in
low bandwidth mode

include/functions.php

index 453f329b4bc3b3b2f47feb50dec95b8543d5cb1c..be0d4e262151ebdec9b005844ed7ab6ac3e90a8c 100755 (executable)
                                                }
                                        }
                                }
+                       }
+
+                       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);
                                }
                        }