X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fmedia%2FMediaTransformOutput.php;h=81b285e99c0f40731b24d1296a7c41dc7f0c6984;hb=32f9dcb2c0dd4a796aba0d5038f922b05ea95714;hp=c49d3f2094869ae6f0966d3e62c27934ff2bdd4f;hpb=a71728c990496101c740a33efa0b238d9fc2417d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/media/MediaTransformOutput.php b/includes/media/MediaTransformOutput.php index c49d3f2094..81b285e99c 100644 --- a/includes/media/MediaTransformOutput.php +++ b/includes/media/MediaTransformOutput.php @@ -27,19 +27,34 @@ * @ingroup Media */ abstract class MediaTransformOutput { - /** - * @var File - */ - var $file; - - var $width, $height, $url, $page, $path, $lang; - /** * @var array Associative array mapping optional supplementary image files * from pixel density (eg 1.5 or 2) to additional URLs. */ public $responsiveUrls = array(); + /** @var File object */ + protected $file; + + /** @var int Image width */ + protected $width; + + /** @var int Image height */ + protected $height; + + /** @var string URL path to the thumb */ + protected $url; + + /** @var bool|string */ + protected $page; + + /** @var bool|string Filesystem path to the thumb */ + protected $path; + + /** @var bool|string Language code, false if not set */ + protected $lang; + + /** @var bool|string Permanent storage path */ protected $storagePath = false; /** @@ -156,6 +171,7 @@ abstract class MediaTransformOutput { $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 @@ -173,6 +189,7 @@ abstract class MediaTransformOutput { return false; } elseif ( FileBackend::isStoragePath( $this->path ) ) { $be = $this->file->getRepo()->getBackend(); + return $be->streamFile( array( 'src' => $this->path, 'headers' => $headers ) )->isOK(); } else { // FS-file return StreamFile::stream( $this->getLocalCopyPath(), $headers ); @@ -224,6 +241,7 @@ abstract class MediaTransformOutput { if ( $title ) { $attribs['title'] = $title; } + return $attribs; } } @@ -342,7 +360,10 @@ class ThumbnailImage extends MediaTransformOutput { 'title' => empty( $options['title'] ) ? $title->getFullText() : $options['title'] ); } elseif ( !empty( $options['desc-link'] ) ) { - $linkAttribs = $this->getDescLinkAttribs( empty( $options['title'] ) ? null : $options['title'], $query ); + $linkAttribs = $this->getDescLinkAttribs( + empty( $options['title'] ) ? null : $options['title'], + $query + ); } elseif ( !empty( $options['file-link'] ) ) { $linkAttribs = array( 'href' => $this->file->getURL() ); } else { @@ -377,7 +398,6 @@ class ThumbnailImage extends MediaTransformOutput { return $this->linkWrap( $linkAttribs, Xml::element( 'img', $attribs ) ); } - } /** @@ -386,7 +406,11 @@ class ThumbnailImage extends MediaTransformOutput { * @ingroup Media */ class MediaTransformError extends MediaTransformOutput { - var $htmlMsg, $textMsg, $width, $height, $url, $path; + /** @var string HTML formatted version of the error */ + private $htmlMsg; + + /** @var string Plain text formatted version of the error */ + private $textMsg; function __construct( $msg, $width, $height /*, ... */ ) { $args = array_slice( func_get_args(), 3 );