X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=blobdiff_plain;f=includes%2Fmedia%2FThumbnailImage.php;h=6e4412ca8fb72aba6352d52096a81af156c3c438;hb=995aad376af72419dd2fe8870954c9b400be4766;hp=36cf4228e5eeb56591a192d631800bbbbc799b9c;hpb=115ebbe89d25522b5a967b87977fc7ecf3188a95;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/media/ThumbnailImage.php b/includes/media/ThumbnailImage.php index 36cf4228e5..6e4412ca8f 100644 --- a/includes/media/ThumbnailImage.php +++ b/includes/media/ThumbnailImage.php @@ -110,7 +110,7 @@ class ThumbnailImage extends MediaTransformOutput { * @return string */ function toHtml( $options = [] ) { - global $wgPriorityHints, $wgElementTiming; + global $wgPriorityHints, $wgPriorityHintsRatio, $wgElementTiming, $wgNativeImageLazyLoading; if ( func_num_args() == 2 ) { throw new MWException( __METHOD__ . ' called in the old style' ); @@ -126,6 +126,10 @@ class ThumbnailImage extends MediaTransformOutput { 'decoding' => 'async', ]; + if ( $wgNativeImageLazyLoading ) { + $attribs['loading'] = 'lazy'; + } + $elementTimingName = 'thumbnail'; if ( $wgPriorityHints @@ -133,8 +137,16 @@ class ThumbnailImage extends MediaTransformOutput { && $this->width * $this->height > 100 * 100 ) { self::$firstNonIconImageRendered = true; - $attribs['importance'] = 'high'; - $elementTimingName = 'thumbnail-high'; + // Generate a random number between 0.01 and 1.0, included + $random = rand( 1, 100 ) / 100.0; + + if ( $random <= $wgPriorityHintsRatio ) { + $attribs['importance'] = 'high'; + $elementTimingName = 'thumbnail-high'; + } else { + // This lets us track that the thumbnail *would* have gotten high priority but didn't. + $elementTimingName = 'thumbnail-top'; + } } if ( $wgElementTiming ) {