Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu...
File: media.php
*
[5500] Fix | Delete
* @param string $filename The file path.
[5501] Fix | Delete
* @param array $image_info Optional. Extended image information (passed by reference).
[5502] Fix | Delete
* @return array|false Array of image information or false on failure.
[5503] Fix | Delete
*/
[5504] Fix | Delete
function wp_getimagesize( $filename, ?array &$image_info = null ) {
[5505] Fix | Delete
// Don't silence errors when in debug mode, unless running unit tests.
[5506] Fix | Delete
if ( defined( 'WP_DEBUG' ) && WP_DEBUG
[5507] Fix | Delete
&& ! defined( 'WP_RUN_CORE_TESTS' )
[5508] Fix | Delete
) {
[5509] Fix | Delete
if ( 2 === func_num_args() ) {
[5510] Fix | Delete
$info = getimagesize( $filename, $image_info );
[5511] Fix | Delete
} else {
[5512] Fix | Delete
$info = getimagesize( $filename );
[5513] Fix | Delete
}
[5514] Fix | Delete
} else {
[5515] Fix | Delete
/*
[5516] Fix | Delete
* Silencing notice and warning is intentional.
[5517] Fix | Delete
*
[5518] Fix | Delete
* getimagesize() has a tendency to generate errors, such as
[5519] Fix | Delete
* "corrupt JPEG data: 7191 extraneous bytes before marker",
[5520] Fix | Delete
* even when it's able to provide image size information.
[5521] Fix | Delete
*
[5522] Fix | Delete
* See https://core.trac.wordpress.org/ticket/42480
[5523] Fix | Delete
*/
[5524] Fix | Delete
if ( 2 === func_num_args() ) {
[5525] Fix | Delete
$info = @getimagesize( $filename, $image_info );
[5526] Fix | Delete
} else {
[5527] Fix | Delete
$info = @getimagesize( $filename );
[5528] Fix | Delete
}
[5529] Fix | Delete
}
[5530] Fix | Delete
[5531] Fix | Delete
if (
[5532] Fix | Delete
! empty( $info ) &&
[5533] Fix | Delete
// Some PHP versions return 0x0 sizes from `getimagesize` for unrecognized image formats, including AVIFs.
[5534] Fix | Delete
! ( empty( $info[0] ) && empty( $info[1] ) )
[5535] Fix | Delete
) {
[5536] Fix | Delete
return $info;
[5537] Fix | Delete
}
[5538] Fix | Delete
[5539] Fix | Delete
/*
[5540] Fix | Delete
* For PHP versions that don't support WebP images,
[5541] Fix | Delete
* extract the image size info from the file headers.
[5542] Fix | Delete
*/
[5543] Fix | Delete
if ( 'image/webp' === wp_get_image_mime( $filename ) ) {
[5544] Fix | Delete
$webp_info = wp_get_webp_info( $filename );
[5545] Fix | Delete
$width = $webp_info['width'];
[5546] Fix | Delete
$height = $webp_info['height'];
[5547] Fix | Delete
[5548] Fix | Delete
// Mimic the native return format.
[5549] Fix | Delete
if ( $width && $height ) {
[5550] Fix | Delete
return array(
[5551] Fix | Delete
$width,
[5552] Fix | Delete
$height,
[5553] Fix | Delete
IMAGETYPE_WEBP,
[5554] Fix | Delete
sprintf(
[5555] Fix | Delete
'width="%d" height="%d"',
[5556] Fix | Delete
$width,
[5557] Fix | Delete
$height
[5558] Fix | Delete
),
[5559] Fix | Delete
'mime' => 'image/webp',
[5560] Fix | Delete
);
[5561] Fix | Delete
}
[5562] Fix | Delete
}
[5563] Fix | Delete
[5564] Fix | Delete
// For PHP versions that don't support AVIF images, extract the image size info from the file headers.
[5565] Fix | Delete
if ( 'image/avif' === wp_get_image_mime( $filename ) ) {
[5566] Fix | Delete
$avif_info = wp_get_avif_info( $filename );
[5567] Fix | Delete
[5568] Fix | Delete
$width = $avif_info['width'];
[5569] Fix | Delete
$height = $avif_info['height'];
[5570] Fix | Delete
[5571] Fix | Delete
// Mimic the native return format.
[5572] Fix | Delete
if ( $width && $height ) {
[5573] Fix | Delete
return array(
[5574] Fix | Delete
$width,
[5575] Fix | Delete
$height,
[5576] Fix | Delete
IMAGETYPE_AVIF,
[5577] Fix | Delete
sprintf(
[5578] Fix | Delete
'width="%d" height="%d"',
[5579] Fix | Delete
$width,
[5580] Fix | Delete
$height
[5581] Fix | Delete
),
[5582] Fix | Delete
'mime' => 'image/avif',
[5583] Fix | Delete
);
[5584] Fix | Delete
}
[5585] Fix | Delete
}
[5586] Fix | Delete
[5587] Fix | Delete
// The image could not be parsed.
[5588] Fix | Delete
return false;
[5589] Fix | Delete
}
[5590] Fix | Delete
[5591] Fix | Delete
/**
[5592] Fix | Delete
* Extracts meta information about an AVIF file: width, height, bit depth, and number of channels.
[5593] Fix | Delete
*
[5594] Fix | Delete
* @since 6.5.0
[5595] Fix | Delete
*
[5596] Fix | Delete
* @param string $filename Path to an AVIF file.
[5597] Fix | Delete
* @return array {
[5598] Fix | Delete
* An array of AVIF image information.
[5599] Fix | Delete
*
[5600] Fix | Delete
* @type int|false $width Image width on success, false on failure.
[5601] Fix | Delete
* @type int|false $height Image height on success, false on failure.
[5602] Fix | Delete
* @type int|false $bit_depth Image bit depth on success, false on failure.
[5603] Fix | Delete
* @type int|false $num_channels Image number of channels on success, false on failure.
[5604] Fix | Delete
* }
[5605] Fix | Delete
*/
[5606] Fix | Delete
function wp_get_avif_info( $filename ) {
[5607] Fix | Delete
$results = array(
[5608] Fix | Delete
'width' => false,
[5609] Fix | Delete
'height' => false,
[5610] Fix | Delete
'bit_depth' => false,
[5611] Fix | Delete
'num_channels' => false,
[5612] Fix | Delete
);
[5613] Fix | Delete
[5614] Fix | Delete
if ( 'image/avif' !== wp_get_image_mime( $filename ) ) {
[5615] Fix | Delete
return $results;
[5616] Fix | Delete
}
[5617] Fix | Delete
[5618] Fix | Delete
// Parse the file using libavifinfo's PHP implementation.
[5619] Fix | Delete
require_once ABSPATH . WPINC . '/class-avif-info.php';
[5620] Fix | Delete
[5621] Fix | Delete
$handle = fopen( $filename, 'rb' );
[5622] Fix | Delete
if ( $handle ) {
[5623] Fix | Delete
$parser = new Avifinfo\Parser( $handle );
[5624] Fix | Delete
$success = $parser->parse_ftyp() && $parser->parse_file();
[5625] Fix | Delete
fclose( $handle );
[5626] Fix | Delete
if ( $success ) {
[5627] Fix | Delete
$results = $parser->features->primary_item_features;
[5628] Fix | Delete
}
[5629] Fix | Delete
}
[5630] Fix | Delete
return $results;
[5631] Fix | Delete
}
[5632] Fix | Delete
[5633] Fix | Delete
/**
[5634] Fix | Delete
* Extracts meta information about a WebP file: width, height, and type.
[5635] Fix | Delete
*
[5636] Fix | Delete
* @since 5.8.0
[5637] Fix | Delete
*
[5638] Fix | Delete
* @param string $filename Path to a WebP file.
[5639] Fix | Delete
* @return array {
[5640] Fix | Delete
* An array of WebP image information.
[5641] Fix | Delete
*
[5642] Fix | Delete
* @type int|false $width Image width on success, false on failure.
[5643] Fix | Delete
* @type int|false $height Image height on success, false on failure.
[5644] Fix | Delete
* @type string|false $type The WebP type: one of 'lossy', 'lossless' or 'animated-alpha'.
[5645] Fix | Delete
* False on failure.
[5646] Fix | Delete
* }
[5647] Fix | Delete
*/
[5648] Fix | Delete
function wp_get_webp_info( $filename ) {
[5649] Fix | Delete
$width = false;
[5650] Fix | Delete
$height = false;
[5651] Fix | Delete
$type = false;
[5652] Fix | Delete
[5653] Fix | Delete
if ( 'image/webp' !== wp_get_image_mime( $filename ) ) {
[5654] Fix | Delete
return compact( 'width', 'height', 'type' );
[5655] Fix | Delete
}
[5656] Fix | Delete
[5657] Fix | Delete
$magic = file_get_contents( $filename, false, null, 0, 40 );
[5658] Fix | Delete
[5659] Fix | Delete
if ( false === $magic ) {
[5660] Fix | Delete
return compact( 'width', 'height', 'type' );
[5661] Fix | Delete
}
[5662] Fix | Delete
[5663] Fix | Delete
// Make sure we got enough bytes.
[5664] Fix | Delete
if ( strlen( $magic ) < 40 ) {
[5665] Fix | Delete
return compact( 'width', 'height', 'type' );
[5666] Fix | Delete
}
[5667] Fix | Delete
[5668] Fix | Delete
/*
[5669] Fix | Delete
* The headers are a little different for each of the three formats.
[5670] Fix | Delete
* Header values based on WebP docs, see https://developers.google.com/speed/webp/docs/riff_container.
[5671] Fix | Delete
*/
[5672] Fix | Delete
switch ( substr( $magic, 12, 4 ) ) {
[5673] Fix | Delete
// Lossy WebP.
[5674] Fix | Delete
case 'VP8 ':
[5675] Fix | Delete
$parts = unpack( 'v2', substr( $magic, 26, 4 ) );
[5676] Fix | Delete
$width = (int) ( $parts[1] & 0x3FFF );
[5677] Fix | Delete
$height = (int) ( $parts[2] & 0x3FFF );
[5678] Fix | Delete
$type = 'lossy';
[5679] Fix | Delete
break;
[5680] Fix | Delete
// Lossless WebP.
[5681] Fix | Delete
case 'VP8L':
[5682] Fix | Delete
$parts = unpack( 'C4', substr( $magic, 21, 4 ) );
[5683] Fix | Delete
$width = (int) ( $parts[1] | ( ( $parts[2] & 0x3F ) << 8 ) ) + 1;
[5684] Fix | Delete
$height = (int) ( ( ( $parts[2] & 0xC0 ) >> 6 ) | ( $parts[3] << 2 ) | ( ( $parts[4] & 0x03 ) << 10 ) ) + 1;
[5685] Fix | Delete
$type = 'lossless';
[5686] Fix | Delete
break;
[5687] Fix | Delete
// Animated/alpha WebP.
[5688] Fix | Delete
case 'VP8X':
[5689] Fix | Delete
// Pad 24-bit int.
[5690] Fix | Delete
$width = unpack( 'V', substr( $magic, 24, 3 ) . "\x00" );
[5691] Fix | Delete
$width = (int) ( $width[1] & 0xFFFFFF ) + 1;
[5692] Fix | Delete
// Pad 24-bit int.
[5693] Fix | Delete
$height = unpack( 'V', substr( $magic, 27, 3 ) . "\x00" );
[5694] Fix | Delete
$height = (int) ( $height[1] & 0xFFFFFF ) + 1;
[5695] Fix | Delete
$type = 'animated-alpha';
[5696] Fix | Delete
break;
[5697] Fix | Delete
}
[5698] Fix | Delete
[5699] Fix | Delete
return compact( 'width', 'height', 'type' );
[5700] Fix | Delete
}
[5701] Fix | Delete
[5702] Fix | Delete
/**
[5703] Fix | Delete
* Gets loading optimization attributes.
[5704] Fix | Delete
*
[5705] Fix | Delete
* This function returns an array of attributes that should be merged into the given attributes array to optimize
[5706] Fix | Delete
* loading performance. Potential attributes returned by this function are:
[5707] Fix | Delete
* - `loading` attribute with a value of "lazy"
[5708] Fix | Delete
* - `fetchpriority` attribute with a value of "high"
[5709] Fix | Delete
* - `decoding` attribute with a value of "async"
[5710] Fix | Delete
*
[5711] Fix | Delete
* If any of these attributes are already present in the given attributes, they will not be modified. Note that no
[5712] Fix | Delete
* element should have both `loading="lazy"` and `fetchpriority="high"`, so the function will trigger a warning in case
[5713] Fix | Delete
* both attributes are present with those values.
[5714] Fix | Delete
*
[5715] Fix | Delete
* @since 6.3.0
[5716] Fix | Delete
*
[5717] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[5718] Fix | Delete
*
[5719] Fix | Delete
* @param string $tag_name The tag name.
[5720] Fix | Delete
* @param array $attr Array of the attributes for the tag.
[5721] Fix | Delete
* @param string $context Context for the element for which the loading optimization attribute is requested.
[5722] Fix | Delete
* @return array Loading optimization attributes.
[5723] Fix | Delete
*/
[5724] Fix | Delete
function wp_get_loading_optimization_attributes( $tag_name, $attr, $context ) {
[5725] Fix | Delete
global $wp_query;
[5726] Fix | Delete
[5727] Fix | Delete
/**
[5728] Fix | Delete
* Filters whether to short-circuit loading optimization attributes.
[5729] Fix | Delete
*
[5730] Fix | Delete
* Returning an array from the filter will effectively short-circuit the loading of optimization attributes,
[5731] Fix | Delete
* returning that value instead.
[5732] Fix | Delete
*
[5733] Fix | Delete
* @since 6.4.0
[5734] Fix | Delete
*
[5735] Fix | Delete
* @param array|false $loading_attrs False by default, or array of loading optimization attributes to short-circuit.
[5736] Fix | Delete
* @param string $tag_name The tag name.
[5737] Fix | Delete
* @param array $attr Array of the attributes for the tag.
[5738] Fix | Delete
* @param string $context Context for the element for which the loading optimization attribute is requested.
[5739] Fix | Delete
*/
[5740] Fix | Delete
$loading_attrs = apply_filters( 'pre_wp_get_loading_optimization_attributes', false, $tag_name, $attr, $context );
[5741] Fix | Delete
[5742] Fix | Delete
if ( is_array( $loading_attrs ) ) {
[5743] Fix | Delete
return $loading_attrs;
[5744] Fix | Delete
}
[5745] Fix | Delete
[5746] Fix | Delete
$loading_attrs = array();
[5747] Fix | Delete
[5748] Fix | Delete
/*
[5749] Fix | Delete
* Skip lazy-loading for the overall block template, as it is handled more granularly.
[5750] Fix | Delete
* The skip is also applicable for `fetchpriority`.
[5751] Fix | Delete
*/
[5752] Fix | Delete
if ( 'template' === $context ) {
[5753] Fix | Delete
/** This filter is documented in wp-includes/media.php */
[5754] Fix | Delete
return apply_filters( 'wp_get_loading_optimization_attributes', $loading_attrs, $tag_name, $attr, $context );
[5755] Fix | Delete
}
[5756] Fix | Delete
[5757] Fix | Delete
// For now this function only supports images and iframes.
[5758] Fix | Delete
if ( 'img' !== $tag_name && 'iframe' !== $tag_name ) {
[5759] Fix | Delete
/** This filter is documented in wp-includes/media.php */
[5760] Fix | Delete
return apply_filters( 'wp_get_loading_optimization_attributes', $loading_attrs, $tag_name, $attr, $context );
[5761] Fix | Delete
}
[5762] Fix | Delete
[5763] Fix | Delete
/*
[5764] Fix | Delete
* Skip programmatically created images within content blobs as they need to be handled together with the other
[5765] Fix | Delete
* images within the post content or widget content.
[5766] Fix | Delete
* Without this clause, they would already be considered within their own context which skews the image count and
[5767] Fix | Delete
* can result in the first post content image being lazy-loaded or an image further down the page being marked as a
[5768] Fix | Delete
* high priority.
[5769] Fix | Delete
*/
[5770] Fix | Delete
if (
[5771] Fix | Delete
'the_content' !== $context && doing_filter( 'the_content' ) ||
[5772] Fix | Delete
'widget_text_content' !== $context && doing_filter( 'widget_text_content' ) ||
[5773] Fix | Delete
'widget_block_content' !== $context && doing_filter( 'widget_block_content' )
[5774] Fix | Delete
) {
[5775] Fix | Delete
/** This filter is documented in wp-includes/media.php */
[5776] Fix | Delete
return apply_filters( 'wp_get_loading_optimization_attributes', $loading_attrs, $tag_name, $attr, $context );
[5777] Fix | Delete
[5778] Fix | Delete
}
[5779] Fix | Delete
[5780] Fix | Delete
/*
[5781] Fix | Delete
* Add `decoding` with a value of "async" for every image unless it has a
[5782] Fix | Delete
* conflicting `decoding` attribute already present.
[5783] Fix | Delete
*/
[5784] Fix | Delete
if ( 'img' === $tag_name ) {
[5785] Fix | Delete
if ( isset( $attr['decoding'] ) ) {
[5786] Fix | Delete
$loading_attrs['decoding'] = $attr['decoding'];
[5787] Fix | Delete
} else {
[5788] Fix | Delete
$loading_attrs['decoding'] = 'async';
[5789] Fix | Delete
}
[5790] Fix | Delete
}
[5791] Fix | Delete
[5792] Fix | Delete
// For any resources, width and height must be provided, to avoid layout shifts.
[5793] Fix | Delete
if ( ! isset( $attr['width'], $attr['height'] ) ) {
[5794] Fix | Delete
/** This filter is documented in wp-includes/media.php */
[5795] Fix | Delete
return apply_filters( 'wp_get_loading_optimization_attributes', $loading_attrs, $tag_name, $attr, $context );
[5796] Fix | Delete
}
[5797] Fix | Delete
[5798] Fix | Delete
/*
[5799] Fix | Delete
* The key function logic starts here.
[5800] Fix | Delete
*/
[5801] Fix | Delete
$maybe_in_viewport = null;
[5802] Fix | Delete
$increase_count = false;
[5803] Fix | Delete
$maybe_increase_count = false;
[5804] Fix | Delete
[5805] Fix | Delete
// Logic to handle a `loading` attribute that is already provided.
[5806] Fix | Delete
if ( isset( $attr['loading'] ) ) {
[5807] Fix | Delete
/*
[5808] Fix | Delete
* Interpret "lazy" as not in viewport. Any other value can be
[5809] Fix | Delete
* interpreted as in viewport (realistically only "eager" or `false`
[5810] Fix | Delete
* to force-omit the attribute are other potential values).
[5811] Fix | Delete
*/
[5812] Fix | Delete
if ( 'lazy' === $attr['loading'] ) {
[5813] Fix | Delete
$maybe_in_viewport = false;
[5814] Fix | Delete
} else {
[5815] Fix | Delete
$maybe_in_viewport = true;
[5816] Fix | Delete
}
[5817] Fix | Delete
}
[5818] Fix | Delete
[5819] Fix | Delete
// Logic to handle a `fetchpriority` attribute that is already provided.
[5820] Fix | Delete
if ( isset( $attr['fetchpriority'] ) && 'high' === $attr['fetchpriority'] ) {
[5821] Fix | Delete
/*
[5822] Fix | Delete
* If the image was already determined to not be in the viewport (e.g.
[5823] Fix | Delete
* from an already provided `loading` attribute), trigger a warning.
[5824] Fix | Delete
* Otherwise, the value can be interpreted as in viewport, since only
[5825] Fix | Delete
* the most important in-viewport image should have `fetchpriority` set
[5826] Fix | Delete
* to "high".
[5827] Fix | Delete
*/
[5828] Fix | Delete
if ( false === $maybe_in_viewport ) {
[5829] Fix | Delete
_doing_it_wrong(
[5830] Fix | Delete
__FUNCTION__,
[5831] Fix | Delete
__( 'An image should not be lazy-loaded and marked as high priority at the same time.' ),
[5832] Fix | Delete
'6.3.0'
[5833] Fix | Delete
);
[5834] Fix | Delete
/*
[5835] Fix | Delete
* Set `fetchpriority` here for backward-compatibility as we should
[5836] Fix | Delete
* not override what a developer decided, even though it seems
[5837] Fix | Delete
* incorrect.
[5838] Fix | Delete
*/
[5839] Fix | Delete
$loading_attrs['fetchpriority'] = 'high';
[5840] Fix | Delete
} else {
[5841] Fix | Delete
$maybe_in_viewport = true;
[5842] Fix | Delete
}
[5843] Fix | Delete
}
[5844] Fix | Delete
[5845] Fix | Delete
if ( null === $maybe_in_viewport ) {
[5846] Fix | Delete
$header_enforced_contexts = array(
[5847] Fix | Delete
'template_part_' . WP_TEMPLATE_PART_AREA_HEADER => true,
[5848] Fix | Delete
'get_header_image_tag' => true,
[5849] Fix | Delete
);
[5850] Fix | Delete
[5851] Fix | Delete
/**
[5852] Fix | Delete
* Filters the header-specific contexts.
[5853] Fix | Delete
*
[5854] Fix | Delete
* @since 6.4.0
[5855] Fix | Delete
*
[5856] Fix | Delete
* @param array $default_header_enforced_contexts Map of contexts for which elements should be considered
[5857] Fix | Delete
* in the header of the page, as $context => $enabled
[5858] Fix | Delete
* pairs. The $enabled should always be true.
[5859] Fix | Delete
*/
[5860] Fix | Delete
$header_enforced_contexts = apply_filters( 'wp_loading_optimization_force_header_contexts', $header_enforced_contexts );
[5861] Fix | Delete
[5862] Fix | Delete
// Consider elements with these header-specific contexts to be in viewport.
[5863] Fix | Delete
if ( isset( $header_enforced_contexts[ $context ] ) ) {
[5864] Fix | Delete
$maybe_in_viewport = true;
[5865] Fix | Delete
$maybe_increase_count = true;
[5866] Fix | Delete
} elseif ( ! is_admin() && in_the_loop() && is_main_query() ) {
[5867] Fix | Delete
/*
[5868] Fix | Delete
* Get the content media count, since this is a main query
[5869] Fix | Delete
* content element. This is accomplished by "increasing"
[5870] Fix | Delete
* the count by zero, as the only way to get the count is
[5871] Fix | Delete
* to call this function.
[5872] Fix | Delete
* The actual count increase happens further below, based
[5873] Fix | Delete
* on the `$increase_count` flag set here.
[5874] Fix | Delete
*/
[5875] Fix | Delete
$content_media_count = wp_increase_content_media_count( 0 );
[5876] Fix | Delete
$increase_count = true;
[5877] Fix | Delete
[5878] Fix | Delete
// If the count so far is below the threshold, `loading` attribute is omitted.
[5879] Fix | Delete
if ( $content_media_count < wp_omit_loading_attr_threshold() ) {
[5880] Fix | Delete
$maybe_in_viewport = true;
[5881] Fix | Delete
} else {
[5882] Fix | Delete
$maybe_in_viewport = false;
[5883] Fix | Delete
}
[5884] Fix | Delete
} elseif (
[5885] Fix | Delete
// Only apply for main query but before the loop.
[5886] Fix | Delete
$wp_query->before_loop && $wp_query->is_main_query()
[5887] Fix | Delete
/*
[5888] Fix | Delete
* Any image before the loop, but after the header has started should not be lazy-loaded,
[5889] Fix | Delete
* except when the footer has already started which can happen when the current template
[5890] Fix | Delete
* does not include any loop.
[5891] Fix | Delete
*/
[5892] Fix | Delete
&& did_action( 'get_header' ) && ! did_action( 'get_footer' )
[5893] Fix | Delete
) {
[5894] Fix | Delete
$maybe_in_viewport = true;
[5895] Fix | Delete
$maybe_increase_count = true;
[5896] Fix | Delete
}
[5897] Fix | Delete
}
[5898] Fix | Delete
[5899] Fix | Delete
/*
[5900] Fix | Delete
* If the element is in the viewport (`true`), potentially add
[5901] Fix | Delete
* `fetchpriority` with a value of "high". Otherwise, i.e. if the element
[5902] Fix | Delete
* is not not in the viewport (`false`) or it is unknown (`null`), add
[5903] Fix | Delete
* `loading` with a value of "lazy".
[5904] Fix | Delete
*/
[5905] Fix | Delete
if ( $maybe_in_viewport ) {
[5906] Fix | Delete
$loading_attrs = wp_maybe_add_fetchpriority_high_attr( $loading_attrs, $tag_name, $attr );
[5907] Fix | Delete
} else {
[5908] Fix | Delete
// Only add `loading="lazy"` if the feature is enabled.
[5909] Fix | Delete
if ( wp_lazy_loading_enabled( $tag_name, $context ) ) {
[5910] Fix | Delete
$loading_attrs['loading'] = 'lazy';
[5911] Fix | Delete
}
[5912] Fix | Delete
}
[5913] Fix | Delete
[5914] Fix | Delete
/*
[5915] Fix | Delete
* If flag was set based on contextual logic above, increase the content
[5916] Fix | Delete
* media count, either unconditionally, or based on whether the image size
[5917] Fix | Delete
* is larger than the threshold.
[5918] Fix | Delete
*/
[5919] Fix | Delete
if ( $increase_count ) {
[5920] Fix | Delete
wp_increase_content_media_count();
[5921] Fix | Delete
} elseif ( $maybe_increase_count ) {
[5922] Fix | Delete
/** This filter is documented in wp-includes/media.php */
[5923] Fix | Delete
$wp_min_priority_img_pixels = apply_filters( 'wp_min_priority_img_pixels', 50000 );
[5924] Fix | Delete
[5925] Fix | Delete
if ( $wp_min_priority_img_pixels <= $attr['width'] * $attr['height'] ) {
[5926] Fix | Delete
wp_increase_content_media_count();
[5927] Fix | Delete
}
[5928] Fix | Delete
}
[5929] Fix | Delete
[5930] Fix | Delete
/**
[5931] Fix | Delete
* Filters the loading optimization attributes.
[5932] Fix | Delete
*
[5933] Fix | Delete
* @since 6.4.0
[5934] Fix | Delete
*
[5935] Fix | Delete
* @param array $loading_attrs The loading optimization attributes.
[5936] Fix | Delete
* @param string $tag_name The tag name.
[5937] Fix | Delete
* @param array $attr Array of the attributes for the tag.
[5938] Fix | Delete
* @param string $context Context for the element for which the loading optimization attribute is requested.
[5939] Fix | Delete
*/
[5940] Fix | Delete
return apply_filters( 'wp_get_loading_optimization_attributes', $loading_attrs, $tag_name, $attr, $context );
[5941] Fix | Delete
}
[5942] Fix | Delete
[5943] Fix | Delete
/**
[5944] Fix | Delete
* Gets the threshold for how many of the first content media elements to not lazy-load.
[5945] Fix | Delete
*
[5946] Fix | Delete
* This function runs the {@see 'wp_omit_loading_attr_threshold'} filter, which uses a default threshold value of 3.
[5947] Fix | Delete
* The filter is only run once per page load, unless the `$force` parameter is used.
[5948] Fix | Delete
*
[5949] Fix | Delete
* @since 5.9.0
[5950] Fix | Delete
*
[5951] Fix | Delete
* @param bool $force Optional. If set to true, the filter will be (re-)applied even if it already has been before.
[5952] Fix | Delete
* Default false.
[5953] Fix | Delete
* @return int The number of content media elements to not lazy-load.
[5954] Fix | Delete
*/
[5955] Fix | Delete
function wp_omit_loading_attr_threshold( $force = false ) {
[5956] Fix | Delete
static $omit_threshold;
[5957] Fix | Delete
[5958] Fix | Delete
// This function may be called multiple times. Run the filter only once per page load.
[5959] Fix | Delete
if ( ! isset( $omit_threshold ) || $force ) {
[5960] Fix | Delete
/**
[5961] Fix | Delete
* Filters the threshold for how many of the first content media elements to not lazy-load.
[5962] Fix | Delete
*
[5963] Fix | Delete
* For these first content media elements, the `loading` attribute will be omitted. By default, this is the case
[5964] Fix | Delete
* for only the very first content media element.
[5965] Fix | Delete
*
[5966] Fix | Delete
* @since 5.9.0
[5967] Fix | Delete
* @since 6.3.0 The default threshold was changed from 1 to 3.
[5968] Fix | Delete
*
[5969] Fix | Delete
* @param int $omit_threshold The number of media elements where the `loading` attribute will not be added. Default 3.
[5970] Fix | Delete
*/
[5971] Fix | Delete
$omit_threshold = apply_filters( 'wp_omit_loading_attr_threshold', 3 );
[5972] Fix | Delete
}
[5973] Fix | Delete
[5974] Fix | Delete
return $omit_threshold;
[5975] Fix | Delete
}
[5976] Fix | Delete
[5977] Fix | Delete
/**
[5978] Fix | Delete
* Increases an internal content media count variable.
[5979] Fix | Delete
*
[5980] Fix | Delete
* @since 5.9.0
[5981] Fix | Delete
* @access private
[5982] Fix | Delete
*
[5983] Fix | Delete
* @param int $amount Optional. Amount to increase by. Default 1.
[5984] Fix | Delete
* @return int The latest content media count, after the increase.
[5985] Fix | Delete
*/
[5986] Fix | Delete
function wp_increase_content_media_count( $amount = 1 ) {
[5987] Fix | Delete
static $content_media_count = 0;
[5988] Fix | Delete
[5989] Fix | Delete
$content_media_count += $amount;
[5990] Fix | Delete
[5991] Fix | Delete
return $content_media_count;
[5992] Fix | Delete
}
[5993] Fix | Delete
[5994] Fix | Delete
/**
[5995] Fix | Delete
* Determines whether to add `fetchpriority='high'` to loading attributes.
[5996] Fix | Delete
*
[5997] Fix | Delete
* @since 6.3.0
[5998] Fix | Delete
* @access private
[5999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function