summaryrefslogtreecommitdiffstats
path: root/wp-includes/media.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--wp-includes/media.php70
1 files changed, 35 insertions, 35 deletions
diff --git a/wp-includes/media.php b/wp-includes/media.php
index bf90a6e..0a8621d 100644
--- a/wp-includes/media.php
+++ b/wp-includes/media.php
@@ -1039,19 +1039,21 @@ function wp_get_attachment_image_src( $attachment_id, $size = 'thumbnail', $icon
* @param string|array $attr {
* Optional. Attributes for the image markup.
*
- * @type string $src Image attachment URL.
- * @type string $class CSS class name or space-separated list of classes.
- * Default `attachment-$size_class size-$size_class`,
- * where `$size_class` is the image size being requested.
- * @type string $alt Image description for the alt attribute.
- * @type string $srcset The 'srcset' attribute value.
- * @type string $sizes The 'sizes' attribute value.
- * @type string|false $loading The 'loading' attribute value. Passing a value of false
- * will result in the attribute being omitted for the image.
- * Defaults to 'lazy', depending on wp_lazy_loading_enabled().
- * @type string $decoding The 'decoding' attribute value. Possible values are
- * 'async' (default), 'sync', or 'auto'. Passing false or an empty
- * string will result in the attribute being omitted.
+ * @type string $src Image attachment URL.
+ * @type string $class CSS class name or space-separated list of classes.
+ * Default `attachment-$size_class size-$size_class`,
+ * where `$size_class` is the image size being requested.
+ * @type string $alt Image description for the alt attribute.
+ * @type string $srcset The 'srcset' attribute value.
+ * @type string $sizes The 'sizes' attribute value.
+ * @type string|false $loading The 'loading' attribute value. Passing a value of false
+ * will result in the attribute being omitted for the image.
+ * Default determined by {@see wp_get_loading_optimization_attributes()}.
+ * @type string $decoding The 'decoding' attribute value. Possible values are
+ * 'async' (default), 'sync', or 'auto'. Passing false or an empty
+ * string will result in the attribute being omitted.
+ * @type string $fetchpriority The 'fetchpriority' attribute value, whether `high`, `low`, or `auto`.
+ * Default determined by {@see wp_get_loading_optimization_attributes()}.
* }
* @return string HTML img element or empty string on failure.
*/
@@ -1363,8 +1365,17 @@ function wp_calculate_image_srcset( $size_array, $image_src, $image_meta, $attac
* If currently on HTTPS, prefer HTTPS URLs when we know they're supported by the domain
* (which is to say, when they share the domain name of the current request).
*/
- if ( is_ssl() && ! str_starts_with( $image_baseurl, 'https' ) && parse_url( $image_baseurl, PHP_URL_HOST ) === $_SERVER['HTTP_HOST'] ) {
- $image_baseurl = set_url_scheme( $image_baseurl, 'https' );
+ if ( is_ssl() && ! str_starts_with( $image_baseurl, 'https' ) ) {
+ // Since the `Host:` header might contain a port we should
+ // compare it against the image URL using the same port.
+ $parsed = parse_url( $image_baseurl );
+ $domain = $parsed['host'];
+ if ( isset( $parsed['port'] ) ) {
+ $domain .= ':' . $parsed['port'];
+ }
+ if ( $_SERVER['HTTP_HOST'] === $domain ) {
+ $image_baseurl = set_url_scheme( $image_baseurl, 'https' );
+ }
}
/*
@@ -2127,7 +2138,7 @@ function wp_img_tag_add_width_and_height_attr( $image, $context, $attachment_id
$image_meta = wp_get_attachment_metadata( $attachment_id );
$size_array = wp_image_src_get_dimensions( $image_src, $image_meta, $attachment_id );
- if ( $size_array ) {
+ if ( $size_array && $size_array[0] && $size_array[1] ) {
// If the width is enforced through style (e.g. in an inline image), calculate the dimension attributes.
$style_width = preg_match( '/style="width:\s*(\d+)px;"/', $image, $match_width ) ? (int) $match_width[1] : 0;
if ( $style_width ) {
@@ -2187,14 +2198,6 @@ function wp_img_tag_add_srcset_and_sizes_attr( $image, $context, $attachment_id
*/
function wp_iframe_tag_add_loading_attr( $iframe, $context ) {
/*
- * Iframes with fallback content (see `wp_filter_oembed_result()`) should not be lazy-loaded because they are
- * visually hidden initially.
- */
- if ( str_contains( $iframe, ' data-secret="' ) ) {
- return $iframe;
- }
-
- /*
* Get loading attribute value to use. This must occur before the conditional check below so that even iframes that
* are ineligible for being lazy-loaded are considered.
*/
@@ -3146,7 +3149,7 @@ add_shortcode( 'playlist', 'wp_playlist_shortcode' );
*/
function wp_mediaelement_fallback( $url ) {
/**
- * Filters the Mediaelement fallback output for no-JS.
+ * Filters the MediaElement fallback output for no-JS.
*
* @since 3.6.0
*
@@ -4822,7 +4825,7 @@ function wp_enqueue_media( $args = array() ) {
'apply' => __( 'Apply' ),
'filterByDate' => __( 'Filter by date' ),
'filterByType' => __( 'Filter by type' ),
- 'searchLabel' => __( 'Search' ),
+ 'searchLabel' => __( 'Search media' ),
'searchMediaLabel' => __( 'Search media' ), // Backward compatibility pre-5.3.
'searchMediaPlaceholder' => __( 'Search media items...' ), // Placeholder (no ellipsis), backward compatibility pre-5.3.
/* translators: %d: Number of attachments found in a search. */
@@ -5076,9 +5079,6 @@ function get_post_galleries( $post, $html = true ) {
$srcs = array();
$shortcode_attrs = shortcode_parse_atts( $shortcode[3] );
- if ( ! is_array( $shortcode_attrs ) ) {
- $shortcode_attrs = array();
- }
// Specify the post ID of the gallery we're viewing if the shortcode doesn't reference another post already.
if ( ! isset( $shortcode_attrs['id'] ) ) {
@@ -5499,7 +5499,7 @@ function wp_show_heic_upload_error( $plupload_settings ) {
* @param array $image_info Optional. Extended image information (passed by reference).
* @return array|false Array of image information or false on failure.
*/
-function wp_getimagesize( $filename, array &$image_info = null ) {
+function wp_getimagesize( $filename, ?array &$image_info = null ) {
// Don't silence errors when in debug mode, unless running unit tests.
if ( defined( 'WP_DEBUG' ) && WP_DEBUG
&& ! defined( 'WP_RUN_CORE_TESTS' )
@@ -5593,12 +5593,12 @@ function wp_getimagesize( $filename, array &$image_info = null ) {
*
* @param string $filename Path to an AVIF file.
* @return array {
- * An array of AVIF image information.
+ * An array of AVIF image information.
*
- * @type int|false $width Image width on success, false on failure.
- * @type int|false $height Image height on success, false on failure.
- * @type int|false $bit_depth Image bit depth on success, false on failure.
- * @type int|false $num_channels Image number of channels on success, false on failure.
+ * @type int|false $width Image width on success, false on failure.
+ * @type int|false $height Image height on success, false on failure.
+ * @type int|false $bit_depth Image bit depth on success, false on failure.
+ * @type int|false $num_channels Image number of channels on success, false on failure.
* }
*/
function wp_get_avif_info( $filename ) {