Merge "Add Priority Hints support"
This commit is contained in:
commit
227a807ef5
2 changed files with 22 additions and 0 deletions
|
|
@ -9045,6 +9045,16 @@ $wgEnableBlockNoticeStats = false;
|
||||||
*/
|
*/
|
||||||
$wgOriginTrials = [];
|
$wgOriginTrials = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable client-side Priority Hints.
|
||||||
|
*
|
||||||
|
* @warning EXPERIMENTAL!
|
||||||
|
*
|
||||||
|
* @since 1.34
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
$wgPriorityHints = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For really cool vim folding this needs to be at the end:
|
* For really cool vim folding this needs to be at the end:
|
||||||
* vim: foldmarker=@{,@} foldmethod=marker
|
* vim: foldmarker=@{,@} foldmethod=marker
|
||||||
|
|
|
||||||
|
|
@ -275,6 +275,8 @@ abstract class MediaTransformOutput {
|
||||||
* @ingroup Media
|
* @ingroup Media
|
||||||
*/
|
*/
|
||||||
class ThumbnailImage extends MediaTransformOutput {
|
class ThumbnailImage extends MediaTransformOutput {
|
||||||
|
private static $firstNonIconImageRendered = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a thumbnail object from a file and parameters.
|
* Get a thumbnail object from a file and parameters.
|
||||||
* If $path is set to null, the output file is treated as a source copy.
|
* 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
|
* @return string
|
||||||
*/
|
*/
|
||||||
function toHtml( $options = [] ) {
|
function toHtml( $options = [] ) {
|
||||||
|
global $wgPriorityHints;
|
||||||
|
|
||||||
if ( count( func_get_args() ) == 2 ) {
|
if ( count( func_get_args() ) == 2 ) {
|
||||||
throw new MWException( __METHOD__ . ' called in the old style' );
|
throw new MWException( __METHOD__ . ' called in the old style' );
|
||||||
}
|
}
|
||||||
|
|
@ -370,6 +374,14 @@ class ThumbnailImage extends MediaTransformOutput {
|
||||||
'decoding' => 'async',
|
'decoding' => 'async',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ( $wgPriorityHints
|
||||||
|
&& !self::$firstNonIconImageRendered
|
||||||
|
&& $this->width * $this->height > 100 * 100 ) {
|
||||||
|
self::$firstBigImageRendered = true;
|
||||||
|
|
||||||
|
$attribs['importance'] = 'high';
|
||||||
|
}
|
||||||
|
|
||||||
if ( !empty( $options['custom-url-link'] ) ) {
|
if ( !empty( $options['custom-url-link'] ) ) {
|
||||||
$linkAttribs = [ 'href' => $options['custom-url-link'] ];
|
$linkAttribs = [ 'href' => $options['custom-url-link'] ];
|
||||||
if ( !empty( $options['title'] ) ) {
|
if ( !empty( $options['title'] ) ) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue