Merge "Fixed and normalized content-disposition for thumbs."
[lhc/web/wiklou.git] / includes / filerepo / file / File.php
index 3d1e270..3b0ea14 100644 (file)
@@ -943,7 +943,7 @@ abstract class File {
                                }
                        } elseif ( $this->repo && $thumb->hasFile() && !$thumb->fileIsSource() ) {
                                // Copy the thumbnail from the file system into storage...
-                               $disposition = FileBackend::makeContentDisposition( 'inline', $this->name );
+                               $disposition = $this->getThumbDisposition( $thumbName );
                                $status = $this->repo->quickImport( $tmpThumbPath, $thumbPath, $disposition );
                                if ( $status->isOK() ) {
                                        $thumb->setStoragePath( $thumbPath );
@@ -968,6 +968,19 @@ abstract class File {
                return is_object( $thumb ) ? $thumb : false;
        }
 
+       /**
+        * @param $thumbName string Thumbnail name
+        * @return string Content-Disposition header value
+        */
+       function getThumbDisposition( $thumbName ) {
+               $fileName = $this->name; // file name to suggest
+               $thumbExt = FileBackend::extensionFromPath( $thumbName );
+               if ( $thumbExt != '' && $thumbExt !== $this->getExtension() ) {
+                       $fileName .= ".$thumbExt";
+               }
+               return FileBackend::makeContentDisposition( 'inline', $fileName );
+       }
+
        /**
         * Hook into transform() to allow migration of thumbnail files
         * STUB