summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2017-02-04 11:32:24 +0300
committerAndrew Dolgov <[email protected]>2017-02-04 11:32:24 +0300
commit0442cbb6c16e22cf172ade58d675c1e2001646d1 (patch)
treef40088063e651415619a8ae1e268e4f04d27712a /include
parent60e97d9e63df7cdbf6fc9ece09ae4bb79e4a5272 (diff)
image cache: send files as content-disposition: attachment; add .png suffix to image urls
Diffstat (limited to 'include')
-rw-r--r--include/functions2.php29
1 files changed, 15 insertions, 14 deletions
diff --git a/include/functions2.php b/include/functions2.php
index b8eff56d2..2b34f287c 100644
--- a/include/functions2.php
+++ b/include/functions2.php
@@ -903,27 +903,28 @@
$entry->setAttribute('rel', 'noopener noreferrer');
}
- if ($entry->hasAttribute('src')) {
- $src = rewrite_relative_url($site_url, $entry->getAttribute('src'));
+ if ($entry->nodeName == 'img') {
+
+ if ($entry->hasAttribute('src')) {
+ $src = rewrite_relative_url($site_url, $entry->getAttribute('src'));
- $cached_filename = CACHE_DIR . '/images/' . sha1($src) . '.png';
+ $cached_filename = CACHE_DIR . '/images/' . sha1($src) . '.png';
- if (file_exists($cached_filename)) {
- $src = SELF_URL_PATH . '/public.php?op=cached_image&hash=' . sha1($src);
+ if (file_exists($cached_filename)) {
+ $src = SELF_URL_PATH . '/public.php?op=cached_image&hash=' . sha1($src) . '.png';
- if ($entry->hasAttribute('srcset')) {
- $entry->removeAttribute('srcset');
- }
+ if ($entry->hasAttribute('srcset')) {
+ $entry->removeAttribute('srcset');
+ }
- if ($entry->hasAttribute('sizes')) {
- $entry->removeAttribute('sizes');
+ if ($entry->hasAttribute('sizes')) {
+ $entry->removeAttribute('sizes');
+ }
}
- }
- $entry->setAttribute('src', $src);
- }
+ $entry->setAttribute('src', $src);
+ }
- if ($entry->nodeName == 'img') {
if ($entry->hasAttribute('src')) {
$is_https_url = parse_url($entry->getAttribute('src'), PHP_URL_SCHEME) === 'https';