From: Gilles Dubuc Date: Tue, 19 Mar 2019 10:22:13 +0000 (+0100) Subject: Add support for Element Timing API X-Git-Tag: 1.34.0-rc.0~2447^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/gestion/rappel_supprimer.php?a=commitdiff_plain;h=e83e1fc1eee3cc49e7a4c148396a7e4416c73f8c;p=lhc%2Fweb%2Fwiklou.git Add support for Element Timing API https://github.com/WICG/element-timing Bug: T216598 Change-Id: Ieda41f5074784957760c17dc15f7c891e56b6795 --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 68d784614a..34b2796242 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -9041,6 +9041,16 @@ $wgOriginTrials = []; */ $wgPriorityHints = false; +/** + * Enable Element Timing. + * + * @warning EXPERIMENTAL! + * + * @since 1.34 + * @var bool + */ +$wgElementTiming = false; + /** * For really cool vim folding this needs to be at the end: * vim: foldmarker=@{,@} foldmethod=marker diff --git a/includes/media/MediaTransformOutput.php b/includes/media/MediaTransformOutput.php index 87b4be7803..48ea4a510f 100644 --- a/includes/media/MediaTransformOutput.php +++ b/includes/media/MediaTransformOutput.php @@ -358,7 +358,7 @@ class ThumbnailImage extends MediaTransformOutput { * @return string */ function toHtml( $options = [] ) { - global $wgPriorityHints; + global $wgPriorityHints, $wgElementTiming; if ( count( func_get_args() ) == 2 ) { throw new MWException( __METHOD__ . ' called in the old style' ); @@ -374,12 +374,19 @@ class ThumbnailImage extends MediaTransformOutput { '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'] ) ) {