* @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.
* @return string
*/
function toHtml( $options = [] ) {
+ global $wgPriorityHints, $wgElementTiming;
+
if ( count( func_get_args() ) == 2 ) {
throw new MWException( __METHOD__ . ' called in the old style' );
}
'decoding' => 'async',
];
+ $elementTimingName = 'thumbnail';
+
+ if ( $wgPriorityHints
+ && !self::$firstNonIconImageRendered
+ && $this->width * $this->height > 100 * 100 ) {
+ self::$firstNonIconImageRendered = true;
+
+ $attribs['importance'] = 'high';
+ $elementTimingName = 'thumbnail-high';
+ }
+
+ if ( $wgElementTiming ) {
+ $attribs['elementtiming'] = $elementTimingName;
+ }
+
if ( !empty( $options['custom-url-link'] ) ) {
$linkAttribs = [ 'href' => $options['custom-url-link'] ];
if ( !empty( $options['title'] ) ) {