[geeklog-cvs] geeklog: Send images 'inline', not as 'attachment'

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Fri Oct 3 04:49:05 EDT 2008


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/12a47f2285a6
changeset: 6408:12a47f2285a6
user:      Dirk Haun <dirk at haun-online.de>
date:      Fri Oct 03 10:48:53 2008 +0200
description:
Send images 'inline', not as 'attachment'

diffstat:

1 file changed, 12 insertions(+), 5 deletions(-)
system/classes/downloader.class.php |   17 ++++++++++++-----

diffs (30 lines):

diff -r 9d6dee6e985c -r 12a47f2285a6 system/classes/downloader.class.php
--- a/system/classes/downloader.class.php	Fri Oct 03 10:18:19 2008 +0200
+++ b/system/classes/downloader.class.php	Fri Oct 03 10:48:53 2008 +0200
@@ -515,14 +515,21 @@
         if ($this->checkExtension($fextension)) {
             // Display file inside browser.
             header('Content-Type: ' . $this->_availableMimeTypes[$fextension]);
-            header('Content-transfer-encoding: binary');
-            header('Content-length: ' . filesize($this->_sourceDirectory . $fileName));
-            header('Content-Disposition: attachment; filename="' . $fileName . '"');
+            header('Content-Transfer-Encoding: binary');
+            header('Content-Length: '
+                   . filesize($this->_sourceDirectory . $fileName));
+
+            // send images as 'inline' everything else as 'attachment'
+            if (substr($this->_availableMimeTypes[$fextension], 0, 6) == 'image/') {
+                header('Content-Disposition: inline; filename="' . $fileName . '"');
+            } else {
+                header('Content-Disposition: attachment; filename="' . $fileName . '"');
+            }
 
             // Send file contents.
             $fp = fopen($this->_sourceDirectory . $fileName, 'rb');
-
-            fpassthru( $fp );
+            fpassthru($fp);
+            fclose($fp);
         }
 
         return true;



More information about the geeklog-cvs mailing list