Merge "Added/Removed spaces around string concatenation"
[lhc/web/wiklou.git] / includes / media / MediaTransformOutput.php
index 1fbe029..2616edb 100644 (file)
@@ -80,7 +80,7 @@ abstract class MediaTransformOutput {
        }
 
        /**
-        * @param $storagePath string The permanent storage path
+        * @param string $storagePath The permanent storage path
         * @return void
         */
        public function setStoragePath( $storagePath ) {
@@ -90,7 +90,7 @@ abstract class MediaTransformOutput {
        /**
         * Fetch HTML for this transform output
         *
-        * @param $options array Associative array of options. Boolean options
+        * @param array $options Associative array of options. Boolean options
         *     should be indicated with a value of true for true, and false or
         *     absent for false.
         *
@@ -151,7 +151,12 @@ abstract class MediaTransformOutput {
                if ( $this->isError() ) {
                        return false;
                } elseif ( $this->path === null ) {
-                       return $this->file->getLocalRefPath();
+                       return $this->file->getLocalRefPath(); // assume thumb was not scaled
+               } elseif ( FileBackend::isStoragePath( $this->path ) ) {
+                       $be = $this->file->getRepo()->getBackend();
+                       // The temp file will be process cached by FileBackend
+                       $fsFile = $be->getLocalReference( array( 'src' => $this->path ) );
+                       return $fsFile ? $fsFile->getPath() : false;
                } else {
                        return $this->path; // may return false
                }
@@ -160,7 +165,7 @@ abstract class MediaTransformOutput {
        /**
         * Stream the file if there were no errors
         *
-        * @param $headers Array Additional HTTP headers to send on success
+        * @param array $headers Additional HTTP headers to send on success
         * @return Bool success
         */
        public function streamFile( $headers = array() ) {
@@ -228,9 +233,9 @@ class ThumbnailImage extends MediaTransformOutput {
         * It may also include a 'page' parameter for multipage files.
         *
         * @param $file File object
-        * @param $url String: URL path to the thumb
+        * @param string $url URL path to the thumb
         * @param $path String|bool|null: filesystem path to the thumb
-        * @param $parameters Array: Associative array of parameters
+        * @param array $parameters Associative array of parameters
         * @private
         */
        function __construct( $file, $url, $path = false, $parameters = array() ) {
@@ -270,7 +275,7 @@ class ThumbnailImage extends MediaTransformOutput {
         * Return HTML <img ... /> tag for the thumbnail, will include
         * width and height attributes and a blank alt text (as required).
         *
-        * @param $options array Associative array of options. Boolean options
+        * @param array $options Associative array of options. Boolean options
         *     should be indicated with a value of true for true, and false or
         *     absent for false.
         *
@@ -296,7 +301,7 @@ class ThumbnailImage extends MediaTransformOutput {
         */
        function toHtml( $options = array() ) {
                if ( count( func_get_args() ) == 2 ) {
-                       throw new MWException( __METHOD__ .' called in the old style' );
+                       throw new MWException( __METHOD__ . ' called in the old style' );
                }
 
                $alt = empty( $options['alt'] ) ? '' : $options['alt'];