summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-03-19 22:41:10 +0400
committerAndrew Dolgov <[email protected]>2013-03-19 22:41:10 +0400
commitbfd61d3f85d9b2554a016e4c2f711a1285ff8818 (patch)
treefd94cb22ce5a2df59ab540a1d8769cbf36f73282 /include
parent2229e6ed6b07d4a28b04689a21c645bdb83652f7 (diff)
rework STRIP_IMAGES to remove embedding; add per-feed control over embedded images (bump schema)
Diffstat (limited to 'include')
-rw-r--r--include/functions.php27
1 files changed, 21 insertions, 6 deletions
diff --git a/include/functions.php b/include/functions.php
index affd4d4dc..1feedcbf0 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -1,6 +1,6 @@
<?php
define('EXPECTED_CONFIG_VERSION', 26);
- define('SCHEMA_VERSION', 105);
+ define('SCHEMA_VERSION', 106);
$fetch_last_error = false;
$pluginhost = false;
@@ -2461,6 +2461,7 @@
num_comments,
comments,
int_id,
+ hide_images,
unread,feed_id,marked,published,link,last_read,orig_feed_id,
last_marked, last_published,
".SUBSTRING_FOR_DATE."(last_read,1,19) as last_read_noms,
@@ -2505,6 +2506,7 @@
"label_cache," .
"link," .
"last_read," .
+ "hide_images," .
"last_marked, last_published, " .
SUBSTRING_FOR_DATE . "(last_read,1,19) as last_read_noms," .
$since_id_part .
@@ -2560,15 +2562,11 @@
}
- function sanitize($link, $str, $force_strip_tags = false, $owner = false, $site_url = false) {
+ function sanitize($link, $str, $force_remove_images = false, $owner = false, $site_url = false) {
if (!$owner) $owner = $_SESSION["uid"];
$res = trim($str); if (!$res) return '';
- if (get_pref($link, "STRIP_IMAGES", $owner)) {
- $res = preg_replace('/<img[^>]+>/is', '', $res);
- }
-
if (strpos($res, "href=") === false)
$res = rewrite_urls($res);
@@ -2605,6 +2603,23 @@
$entry->setAttribute('src', $src);
}
+
+ if ($entry->nodeName == 'img') {
+ if (get_pref($link, "STRIP_IMAGES", $owner) || $force_remove_images) {
+
+ $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');
+
+ $p->appendChild($a);
+
+ $entry->parentNode->replaceChild($p, $entry);
+ }
+ }
}
if (strtolower($entry->nodeName) == "a") {