Merge "Move brace matching rules to Preprocessor class"
[lhc/web/wiklou.git] / includes / media / MediaTransformOutput.php
index d9327fb..1dd8519 100644 (file)
@@ -352,6 +352,11 @@ class ThumbnailImage extends MediaTransformOutput {
 
                $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'] );
                        if ( !empty( $options['title'] ) ) {
@@ -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()
+                       );
+       }
+}