Changeset 56191 for trunk/src/wp-includes/media.php
- Timestamp:
- 07/10/2023 10:36:06 PM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r56164 r56191 218 218 $img_url_basename = wp_basename( $img_url ); 219 219 220 // If the file isn't an image, attempt to replace its URL with a rendered image from its meta. 221 // Otherwise, a non-image type could be returned. 220 /* 221 * If the file isn't an image, attempt to replace its URL with a rendered image from its meta. 222 * Otherwise, a non-image type could be returned. 223 */ 222 224 if ( ! $is_image ) { 223 225 if ( ! empty( $meta['sizes']['full'] ) ) { … … 653 655 } 654 656 655 // The return array matches the parameters to imagecopyresampled(). 656 // int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h 657 /* 658 * The return array matches the parameters to imagecopyresampled(). 659 * int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h 660 */ 657 661 return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h ); 658 662 } … … 1078 1082 } 1079 1083 1080 // If the default value of `lazy` for the `loading` attribute is overridden 1081 // to omit the attribute for this image, ensure it is not included. 1084 /* 1085 * If the default value of `lazy` for the `loading` attribute is overridden 1086 * to omit the attribute for this image, ensure it is not included. 1087 */ 1082 1088 if ( isset( $attr['loading'] ) && ! $attr['loading'] ) { 1083 1089 unset( $attr['loading'] ); … … 1760 1766 */ 1761 1767 function wp_lazy_loading_enabled( $tag_name, $context ) { 1762 // By default add to all 'img' and 'iframe' tags. 1763 // See https://html.spec.whatwg.org/multipage/embedded-content.html#attr-img-loading 1764 // See https://html.spec.whatwg.org/multipage/iframe-embed-object.html#attr-iframe-loading 1768 /* 1769 * By default add to all 'img' and 'iframe' tags. 1770 * See https://html.spec.whatwg.org/multipage/embedded-content.html#attr-img-loading 1771 * See https://html.spec.whatwg.org/multipage/iframe-embed-object.html#attr-iframe-loading 1772 */ 1765 1773 $default = ( 'img' === $tag_name || 'iframe' === $tag_name ); 1766 1774 … … 1826 1834 1827 1835 if ( $attachment_id ) { 1828 // If exactly the same image tag is used more than once, overwrite it. 1829 // All identical tags will be replaced later with 'str_replace()'. 1836 /* 1837 * If exactly the same image tag is used more than once, overwrite it. 1838 * All identical tags will be replaced later with 'str_replace()'. 1839 */ 1830 1840 $images[ $tag ] = $attachment_id; 1831 1841 break; … … 2041 2051 */ 2042 2052 function wp_img_tag_add_decoding_attr( $image, $context ) { 2043 // Only apply the decoding attribute to images that have a src attribute that 2044 // starts with a double quote, ensuring escaped JSON is also excluded. 2053 /* 2054 * Only apply the decoding attribute to images that have a src attribute that 2055 * starts with a double quote, ensuring escaped JSON is also excluded. 2056 */ 2045 2057 if ( ! str_contains( $image, ' src="' ) ) { 2046 2058 return $image; … … 2159 2171 */ 2160 2172 function wp_iframe_tag_add_loading_attr( $iframe, $context ) { 2161 // Iframes with fallback content (see `wp_filter_oembed_result()`) should not be lazy-loaded because they are 2162 // visually hidden initially. 2173 /* 2174 * Iframes with fallback content (see `wp_filter_oembed_result()`) should not be lazy-loaded because they are 2175 * visually hidden initially. 2176 */ 2163 2177 if ( str_contains( $iframe, ' data-secret="' ) ) { 2164 2178 return $iframe; 2165 2179 } 2166 2180 2167 // Get loading attribute value to use. This must occur before the conditional check below so that even iframes that 2168 // are ineligible for being lazy-loaded are considered. 2181 /* 2182 * Get loading attribute value to use. This must occur before the conditional check below so that even iframes that 2183 * are ineligible for being lazy-loaded are considered. 2184 */ 2169 2185 $optimization_attrs = wp_get_loading_optimization_attributes( 2170 2186 'iframe', … … 3523 3539 } 3524 3540 3525 // MediaElement.js has issues with some URL formats for Vimeo and YouTube, 3526 // so update the URL to prevent the ME.js player from breaking. 3541 /* 3542 * MediaElement.js has issues with some URL formats for Vimeo and YouTube, 3543 * so update the URL to prevent the ME.js player from breaking. 3544 */ 3527 3545 if ( 'mediaelement' === $library ) { 3528 3546 if ( $is_youtube ) { … … 3991 4009 $file_info = wp_check_filetype( $args['path'] ); 3992 4010 3993 // If $file_info['type'] is false, then we let the editor attempt to 3994 // figure out the file type, rather than forcing a failure based on extension. 4011 /* 4012 * If $file_info['type'] is false, then we let the editor attempt to 4013 * figure out the file type, rather than forcing a failure based on extension. 4014 */ 3995 4015 if ( isset( $file_info ) && $file_info['type'] ) { 3996 4016 $args['mime_type'] = $file_info['type']; … … 4089 4109 ! call_user_func( array( $implementation, 'supports_mime_type' ), $args['output_mime_type'] ) 4090 4110 ) { 4091 // This implementation supports the imput type but not the output type. 4092 // Keep looking to see if we can find an implementation that supports both. 4111 /* 4112 * This implementation supports the imput type but not the output type. 4113 * Keep looking to see if we can find an implementation that supports both. 4114 */ 4093 4115 $supports_input = $implementation; 4094 4116 continue; … … 4383 4405 $size_meta = $meta['sizes'][ $size ]; 4384 4406 4385 // We have the actual image size, but might need to further constrain it if content_width is narrower. 4386 // Thumbnail, medium, and full sizes are also checked against the site's height/width options. 4407 /* 4408 * We have the actual image size, but might need to further constrain it if content_width is narrower. 4409 * Thumbnail, medium, and full sizes are also checked against the site's height/width options. 4410 */ 4387 4411 list( $width, $height ) = image_constrain_size_for_editor( $size_meta['width'], $size_meta['height'], $size, 'edit' ); 4388 4412 … … 4514 4538 $args = wp_parse_args( $args, $defaults ); 4515 4539 4516 // We're going to pass the old thickbox media tabs to `media_upload_tabs` 4517 // to ensure plugins will work. We will then unset those tabs. 4540 /* 4541 * We're going to pass the old thickbox media tabs to `media_upload_tabs` 4542 * to ensure plugins will work. We will then unset those tabs. 4543 */ 4518 4544 $tabs = array( 4519 4545 // handler action suffix => tab label … … 4859 4885 $strings['settings'] = $settings; 4860 4886 4861 // Ensure we enqueue media-editor first, that way media-views 4862 // is registered internally before we try to localize it. See #24724. 4887 /* 4888 * Ensure we enqueue media-editor first, that way media-views 4889 * is registered internally before we try to localize it. See #24724. 4890 */ 4863 4891 wp_enqueue_script( 'media-editor' ); 4864 4892 wp_localize_script( 'media-views', '_wpMediaViewsL10n', $strings ); … … 5455 5483 } 5456 5484 5457 // For PHP versions that don't support WebP images, 5458 // extract the image size info from the file headers. 5485 /* 5486 * For PHP versions that don't support WebP images, 5487 * extract the image size info from the file headers. 5488 */ 5459 5489 if ( 'image/webp' === wp_get_image_mime( $filename ) ) { 5460 5490 $webp_info = wp_get_webp_info( $filename ); … … 5517 5547 } 5518 5548 5519 // The headers are a little different for each of the three formats. 5520 // Header values based on WebP docs, see https://developers.google.com/speed/webp/docs/riff_container. 5549 /* 5550 * The headers are a little different for each of the three formats. 5551 * Header values based on WebP docs, see https://developers.google.com/speed/webp/docs/riff_container. 5552 */ 5521 5553 switch ( substr( $magic, 12, 4 ) ) { 5522 5554 // Lossy WebP.
Note: See TracChangeset
for help on using the changeset viewer.