X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=blobdiff_plain;f=includes%2Fmedia%2FMediaTransformOutput.php;h=cee5bbf23a76dbf11bc4e50d0c130a25582c1e08;hb=67bfdc7a68940d901e585eadd984a2074bf0216a;hp=bf08de61cd0be32c81cc2bcc6578233d07bb5ad4;hpb=31003d22ea9e124498df91809f8a7113b32767fb;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/media/MediaTransformOutput.php b/includes/media/MediaTransformOutput.php index bf08de61cd..cee5bbf23a 100644 --- a/includes/media/MediaTransformOutput.php +++ b/includes/media/MediaTransformOutput.php @@ -36,21 +36,30 @@ abstract class MediaTransformOutput { protected $storagePath = false; /** - * Get the width of the output box + * @return integer Width of the output box */ public function getWidth() { return $this->width; } /** - * Get the height of the output box + * @return integer Height of the output box */ public function getHeight() { return $this->height; } /** - * @return string The thumbnail URL + * Get the final extension of the thumbnail. + * Returns false for scripted transformations. + * @return string|false + */ + public function getExtension() { + return $this->path ? FileBackend::extensionFromPath( $this->path ) : false; + } + + /** + * @return string|false The thumbnail URL */ public function getUrl() { return $this->url; @@ -84,7 +93,7 @@ abstract class MediaTransformOutput { * custom-url-link Custom URL to link to * custom-title-link Custom Title object to link to * valign vertical-align property, if the output is an inline element - * img-class Class applied to the tag, if there is such a tag + * img-class Class applied to the "" tag, if there is such a tag * * For images, desc-link and file-link are implemented as a click-through. For * sounds and videos, they may be displayed in other ways. @@ -106,7 +115,7 @@ abstract class MediaTransformOutput { * This will return false if there was an error, the * thumbnail is to be handled client-side only, or if * transformation was deferred via TRANSFORM_LATER. - * + * * @return Bool */ public function hasFile() { @@ -148,7 +157,14 @@ abstract class MediaTransformOutput { * @return Bool success */ public function streamFile( $headers = array() ) { - return $this->path && StreamFile::stream( $this->getLocalCopyPath(), $headers ); + if ( !$this->path ) { + 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 ); + } } /** @@ -198,7 +214,7 @@ class ThumbnailImage extends MediaTransformOutput { * Get a thumbnail object from a file and parameters. * If $path is set to null, the output file is treated as a source copy. * If $path is set to false, no output file will be created. - * + * * @param $file File object * @param $url String: URL path to the thumb * @param $width Integer: file's width @@ -237,6 +253,9 @@ class ThumbnailImage extends MediaTransformOutput { * custom-url-link Custom URL to link to * custom-title-link Custom Title object to link to * custom target-link Value of the target attribute, for custom-target-link + * parser-extlink-* Attributes added by parser for external links: + * parser-extlink-rel: add rel="nofollow" + * parser-extlink-target: link target, but overridden by custom-target-link * * For images, desc-link and file-link are implemented as a click-through. For * sounds and videos, they may be displayed in other ways. @@ -259,6 +278,11 @@ class ThumbnailImage extends MediaTransformOutput { } if ( !empty( $options['custom-target-link'] ) ) { $linkAttribs['target'] = $options['custom-target-link']; + } elseif ( !empty( $options['parser-extlink-target'] ) ) { + $linkAttribs['target'] = $options['parser-extlink-target']; + } + if ( !empty( $options['parser-extlink-rel'] ) ) { + $linkAttribs['rel'] = $options['parser-extlink-rel']; } } elseif ( !empty( $options['custom-title-link'] ) ) { $title = $options['custom-title-link']; @@ -342,6 +366,6 @@ class TransformParameterError extends MediaTransformError { parent::__construct( 'thumbnail_error', max( isset( $params['width'] ) ? $params['width'] : 0, 120 ), max( isset( $params['height'] ) ? $params['height'] : 0, 120 ), - wfMsg( 'thumbnail_invalid_params' ) ); + wfMessage( 'thumbnail_invalid_params' )->text() ); } }