diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
commit | 1de335ad3f395ca6861085393ba366a9e3fb4a0d (patch) | |
tree | f1fdd326034e05177596851be6a7127615d81498 /includes/media/MediaTransformOutput.php | |
parent | 9c75fa8ff6d4d38ef552c00fef5969fb154765e8 (diff) | |
parent | f6d65e533c62f6deb21342d4901ece24497b433e (diff) |
Merge commit 'f6d65'
# Conflicts:
# skins/ArchLinux/ArchLinux.php
Diffstat (limited to 'includes/media/MediaTransformOutput.php')
-rw-r--r-- | includes/media/MediaTransformOutput.php | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/includes/media/MediaTransformOutput.php b/includes/media/MediaTransformOutput.php index bc9e9173..1dd85191 100644 --- a/includes/media/MediaTransformOutput.php +++ b/includes/media/MediaTransformOutput.php @@ -348,9 +348,14 @@ class ThumbnailImage extends MediaTransformOutput { throw new MWException( __METHOD__ . ' called in the old style' ); } - $alt = empty( $options['alt'] ) ? '' : $options['alt']; + $alt = isset( $options['alt'] ) ? $options['alt'] : ''; - $query = empty( $options['desc-query'] ) ? '' : $options['desc-query']; + $query = isset( $options['desc-query'] ) ? $options['desc-query'] : ''; + + $attribs = array( + 'alt' => $alt, + 'src' => $this->url, + ); if ( !empty( $options['custom-url-link'] ) ) { $linkAttribs = array( 'href' => $options['custom-url-link'] ); @@ -381,13 +386,11 @@ class ThumbnailImage extends MediaTransformOutput { $linkAttribs = array( 'href' => $this->file->getURL() ); } else { $linkAttribs = false; + if ( !empty( $options['title'] ) ) { + $attribs['title'] = $options['title']; + } } - $attribs = array( - 'alt' => $alt, - 'src' => $this->url, - ); - if ( empty( $options['no-dimensions'] ) ) { $attribs['width'] = $this->width; $attribs['height'] = $this->height; @@ -410,7 +413,7 @@ class ThumbnailImage extends MediaTransformOutput { $attribs['srcset'] = Html::srcSet( $this->responsiveUrls ); } - wfRunHooks( 'ThumbnailBeforeProduceHTML', array( $this, &$attribs, &$linkAttribs ) ); + Hooks::run( 'ThumbnailBeforeProduceHTML', array( $this, &$attribs, &$linkAttribs ) ); return $this->linkWrap( $linkAttribs, Xml::element( 'img', $attribs ) ); } @@ -474,3 +477,24 @@ class TransformParameterError extends MediaTransformError { wfMessage( 'thumbnail_invalid_params' )->text() ); } } + +/** + * Shortcut class for parameter file size errors + * + * @ingroup Media + * @since 1.25 + */ +class TransformTooBigImageAreaError extends MediaTransformError { + function __construct( $params, $maxImageArea ) { + $msg = wfMessage( 'thumbnail_toobigimagearea' ); + + parent::__construct( 'thumbnail_error', + max( isset( $params['width'] ) ? $params['width'] : 0, 120 ), + max( isset( $params['height'] ) ? $params['height'] : 0, 120 ), + $msg->rawParams( + $msg->getLanguage()->formatComputingNumbers( + $maxImageArea, 1000, "size-$1pixel" ) + )->text() + ); + } +} |