Merge "Always set a title on images when provided"
[lhc/web/wiklou.git] / includes / media / MediaTransformOutput.php
index bc9e917..98f7552 100644 (file)
@@ -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 ) );
        }