This commit is contained in:
Hanson.xyz Dev
2026-01-04 17:50:08 -06:00
parent 7e45ce0756
commit acc8ac87a0
4131 changed files with 232562 additions and 250244 deletions
+62 -48
View File
@@ -824,12 +824,15 @@ function image_get_intermediate_size( $post_id, $size = 'thumbnail' ) {
}
$data = array_shift( $candidates );
} elseif ( ! empty( $imagedata['sizes']['thumbnail'] )
&& $size[0] <= $imagedata['sizes']['thumbnail']['width']
&& $size[1] <= $imagedata['sizes']['thumbnail']['width']
) {
/*
* When the size requested is smaller than the thumbnail dimensions, we
* fall back to the thumbnail size to maintain backward compatibility with
* pre 4.6 versions of WordPress.
*/
} elseif ( ! empty( $imagedata['sizes']['thumbnail'] ) && $imagedata['sizes']['thumbnail']['width'] >= $size[0] && $imagedata['sizes']['thumbnail']['width'] >= $size[1] ) {
* When the size requested is smaller than the thumbnail dimensions, we
* fall back to the thumbnail size to maintain backward compatibility with
* pre-4.6 versions of WordPress.
*/
$data = $imagedata['sizes']['thumbnail'];
} else {
return false;
@@ -1089,10 +1092,19 @@ function wp_get_attachment_image( $attachment_id, $size = 'thumbnail', $icon = f
*
* @param string $context The context. Default 'wp_get_attachment_image'.
*/
$context = apply_filters( 'wp_get_attachment_image_context', 'wp_get_attachment_image' );
$attr = wp_parse_args( $attr, $default_attr );
$attr['width'] = $width;
$attr['height'] = $height;
$context = apply_filters( 'wp_get_attachment_image_context', 'wp_get_attachment_image' );
$attr = wp_parse_args( $attr, $default_attr );
// Ensure that the `$width` doesn't overwrite an already valid user-provided width.
if ( ! isset( $attr['width'] ) || ! is_numeric( $attr['width'] ) ) {
$attr['width'] = $width;
}
// Ensure that the `$height` doesn't overwrite an already valid user-provided height.
if ( ! isset( $attr['height'] ) || ! is_numeric( $attr['height'] ) ) {
$attr['height'] = $height;
}
$loading_optimization_attr = wp_get_loading_optimization_attributes(
'img',
@@ -1158,6 +1170,7 @@ function wp_get_attachment_image( $attachment_id, $size = 'thumbnail', $icon = f
* Filters the list of attachment image attributes.
*
* @since 2.8.0
* @since 6.8.2 The `$attr` array includes `width` and `height` attributes.
*
* @param string[] $attr Array of attribute values for the image markup, keyed by attribute name.
* See wp_get_attachment_image().
@@ -1167,13 +1180,14 @@ function wp_get_attachment_image( $attachment_id, $size = 'thumbnail', $icon = f
*/
$attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $size );
if ( isset( $attr['height'] ) && is_numeric( $attr['height'] ) ) {
$height = absint( $attr['height'] );
}
if ( isset( $attr['width'] ) && is_numeric( $attr['width'] ) ) {
$width = absint( $attr['width'] );
}
unset( $attr['height'], $attr['width'] );
if ( isset( $attr['height'] ) && is_numeric( $attr['height'] ) ) {
$height = absint( $attr['height'] );
}
unset( $attr['width'], $attr['height'] );
$attr = array_map( 'esc_attr', $attr );
$hwstring = image_hwstring( $width, $height );
$html = rtrim( "<img $hwstring" );
@@ -2067,25 +2081,37 @@ function wp_sizes_attribute_includes_valid_auto( string $sizes_attr ): bool {
}
/**
* Prints a CSS rule to fix potential visual issues with images using `sizes=auto`.
* Enqueues a CSS rule to fix potential visual issues with images using `sizes=auto`.
*
* This rule overrides the similar rule in the default user agent stylesheet, to avoid images that use e.g.
* `width: auto` or `width: fit-content` to appear smaller.
*
* @since 6.7.1
* @since 6.9.0
*
* @see https://html.spec.whatwg.org/multipage/rendering.html#img-contain-size
* @see https://core.trac.wordpress.org/ticket/62413
* @see https://core.trac.wordpress.org/ticket/62731
*/
function wp_print_auto_sizes_contain_css_fix() {
function wp_enqueue_img_auto_sizes_contain_css_fix(): void {
// Back-compat for plugins that disable functionality by unhooking this action.
$priority = has_action( 'wp_head', 'wp_print_auto_sizes_contain_css_fix' );
if ( false === $priority ) {
return;
}
remove_action( 'wp_head', 'wp_print_auto_sizes_contain_css_fix', $priority );
/** This filter is documented in wp-includes/media.php */
$add_auto_sizes = apply_filters( 'wp_img_tag_add_auto_sizes', true );
if ( ! $add_auto_sizes ) {
return;
}
?>
<style>img:is([sizes="auto" i], [sizes^="auto," i]) { contain-intrinsic-size: 3000px 1500px }</style>
<?php
$handle = 'wp-img-auto-sizes-contain';
wp_register_style( $handle, false );
wp_add_inline_style( $handle, 'img:is([sizes=auto i],[sizes^="auto," i]){contain-intrinsic-size:3000px 1500px}' );
// Make sure inline style is printed first since it was previously printed at wp_head priority 1 and this preserves the CSS cascade.
array_unshift( wp_styles()->queue, $handle );
}
/**
@@ -2136,12 +2162,12 @@ function wp_img_tag_add_loading_optimization_attrs( $image, $context ) {
*
* @since 6.1.0
*
* @param string|false|null $value The `decoding` attribute value. Returning a falsey value
* will result in the attribute being omitted for the image.
* Otherwise, it may be: 'async', 'sync', or 'auto'. Defaults to false.
* @param string $image The HTML `img` tag to be filtered.
* @param string $context Additional context about how the function was called
* or where the img tag is.
* @param string|false|null $value The `decoding` attribute value. Returning a falsey value
* will result in the attribute being omitted for the image.
* Otherwise, it may be: 'async', 'sync', or 'auto'. Defaults to false.
* @param string $image The HTML `img` tag to be filtered.
* @param string $context Additional context about how the function was called
* or where the img tag is.
*/
$filtered_decoding_attr = apply_filters(
'wp_img_tag_add_decoding_attr',
@@ -2998,9 +3024,6 @@ function wp_underscore_playlist_templates() {
function wp_playlist_scripts( $type ) {
wp_enqueue_style( 'wp-mediaelement' );
wp_enqueue_script( 'wp-playlist' );
?>
<!--[if lt IE 9]><script>document.createElement('<?php echo esc_js( $type ); ?>');</script><![endif]-->
<?php
add_action( 'wp_footer', 'wp_underscore_playlist_templates', 0 );
add_action( 'admin_footer', 'wp_underscore_playlist_templates', 0 );
}
@@ -3048,6 +3071,8 @@ function wp_playlist_shortcode( $attr ) {
static $instance = 0;
++$instance;
static $is_loaded = false;
if ( ! empty( $attr['ids'] ) ) {
// 'ids' is explicitly ordered, unless you specify otherwise.
if ( empty( $attr['orderby'] ) ) {
@@ -3229,7 +3254,7 @@ function wp_playlist_shortcode( $attr ) {
ob_start();
if ( 1 === $instance ) {
if ( ! $is_loaded ) {
/**
* Prints and enqueues playlist scripts, styles, and JavaScript templates.
*
@@ -3239,6 +3264,7 @@ function wp_playlist_shortcode( $attr ) {
* @param string $style The 'theme' for the playlist. Core provides 'light' and 'dark'.
*/
do_action( 'wp_playlist_scripts', $atts['type'], $atts['style'] );
$is_loaded = true;
}
?>
<div class="wp-playlist wp-<?php echo $safe_type; ?>-playlist wp-playlist-<?php echo $safe_style; ?>">
@@ -3263,7 +3289,7 @@ function wp_playlist_shortcode( $attr ) {
?>
</ol>
</noscript>
<script type="application/json" class="wp-playlist-script"><?php echo wp_json_encode( $data ); ?></script>
<script type="application/json" class="wp-playlist-script"><?php echo wp_json_encode( $data, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?></script>
</div>
<?php
return ob_get_clean();
@@ -3508,14 +3534,7 @@ function wp_audio_shortcode( $attr, $content = '' ) {
}
}
$html = '';
if ( 'mediaelement' === $library && 1 === $instance ) {
$html .= "<!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->\n";
}
$html .= sprintf( '<audio %s controls="controls">', implode( ' ', $attr_strings ) );
$html = sprintf( '<audio %s controls="controls">', implode( ' ', $attr_strings ) );
$fileurl = '';
$source = '<source type="%s" src="%s" />';
@@ -3793,14 +3812,7 @@ function wp_video_shortcode( $attr, $content = '' ) {
}
}
$html = '';
if ( 'mediaelement' === $library && 1 === $instance ) {
$html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n";
}
$html .= sprintf( '<video %s controls="controls">', implode( ' ', $attr_strings ) );
$html = sprintf( '<video %s controls="controls">', implode( ' ', $attr_strings ) );
$fileurl = '';
$source = '<source type="%s" src="%s" />';
@@ -4438,7 +4450,7 @@ function wp_plupload_default_settings() {
'limitExceeded' => is_multisite() && ! is_upload_space_available(),
);
$script = 'var _wpPluploadSettings = ' . wp_json_encode( $settings ) . ';';
$script = 'var _wpPluploadSettings = ' . wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ';';
if ( $data ) {
$script = "$data\n$script";
@@ -5582,6 +5594,8 @@ function wpview_media_sandbox_styles() {
/**
* Registers the personal data exporter for media.
*
* @since 4.9.6
*
* @param array[] $exporters An array of personal data exporters, keyed by their ID.
* @return array[] Updated array of personal data exporters.
*/
@@ -5815,7 +5829,7 @@ function wp_getimagesize( $filename, ?array &$image_info = null ) {
return array(
$size['width'],
$size['height'],
IMAGETYPE_HEIC,
IMAGETYPE_HEIF,
sprintf(
'width="%d" height="%d"',
$size['width'],