Merge "Block: Explicit convert Message to string"
[lhc/web/wiklou.git] / includes / media / MediaTransformOutput.php
index 12048a9..87b4be7 100644 (file)
@@ -275,6 +275,8 @@ abstract class MediaTransformOutput {
  * @ingroup Media
  */
 class ThumbnailImage extends MediaTransformOutput {
+       private static $firstNonIconImageRendered = false;
+
        /**
         * Get a thumbnail object from a file and parameters.
         * If $path is set to null, the output file is treated as a source copy.
@@ -356,6 +358,8 @@ class ThumbnailImage extends MediaTransformOutput {
         * @return string
         */
        function toHtml( $options = [] ) {
+               global $wgPriorityHints;
+
                if ( count( func_get_args() ) == 2 ) {
                        throw new MWException( __METHOD__ . ' called in the old style' );
                }
@@ -370,6 +374,14 @@ class ThumbnailImage extends MediaTransformOutput {
                        'decoding' => 'async',
                ];
 
+               if ( $wgPriorityHints
+                       && !self::$firstNonIconImageRendered
+                       && $this->width * $this->height > 100 * 100 ) {
+                       self::$firstNonIconImageRendered = true;
+
+                       $attribs['importance'] = 'high';
+               }
+
                if ( !empty( $options['custom-url-link'] ) ) {
                        $linkAttribs = [ 'href' => $options['custom-url-link'] ];
                        if ( !empty( $options['title'] ) ) {