Ticket #28408: 28408.patch
File 28408.patch, 19.2 KB (added by , 9 years ago) |
---|
-
src/wp-includes/media.php
59 59 // if no width is set, default to the theme content width if available 60 60 } 61 61 elseif ( $size == 'large' ) { 62 // We're inserting a large size image into the editor. If it's a really 63 // big image we'll scale it down to fit reasonably within the editor 64 // itself, and within the theme's content width if it's known. The user 65 // can resize it in the editor if they wish. 62 /* 63 * We're inserting a large size image into the editor. If it's a really 64 * big image we'll scale it down to fit reasonably within the editor 65 * itself, and within the theme's content width if it's known. The user 66 * can resize it in the editor if they wish. 67 */ 66 68 $max_width = intval(get_option('large_size_w')); 67 69 $max_height = intval(get_option('large_size_h')); 68 70 if ( intval($content_width) > 0 ) … … 109 111 * 110 112 * @since 2.5.0 111 113 * 112 * @param int|string $width Optional. Width attribute value.114 * @param int|string $width Optional. Width attribute value. 113 115 * @param int|string $height Optional. Height attribute value. 114 116 * @return string HTML attributes for width and, or height. 115 117 */ … … 140 142 * 141 143 * @since 2.5.0 142 144 * 143 * @param int $idAttachment ID for image.145 * @param int $id Attachment ID for image. 144 146 * @param array|string $size Optional, default is 'medium'. Size of image, either array or string. 145 147 * @return bool|array False on failure, array on success. 146 148 */ … … 297 299 * 298 300 * @since 2.5.0 299 301 * 300 * @param int $idAttachment ID.301 * @param string $alt Image Description for the alt attribute.302 * @param int $id Attachment ID. 303 * @param string $alt Image Description for the alt attribute. 302 304 * @param string $title Image Description for the title attribute. 303 305 * @param string $align Part of the class name for aligning the image. 304 * @param string $size Optional. Default is 'medium'.306 * @param string $size Optional. The registered image size. Default is 'medium'. 305 307 * @return string HTML IMG element for given image attachment 306 308 */ 307 309 function get_image_tag($id, $alt, $title, $align, $size='medium') { … … 352 354 * 353 355 * @since 2.5.0 354 356 * 355 * @param int $current_width Current width of the image.357 * @param int $current_width Current width of the image. 356 358 * @param int $current_height Current height of the image. 357 * @param int $max_width Optional. Maximum wanted width.358 * @param int $max_height Optional. Maximum wanted height.359 * @param int $max_width Optional. Maximum wanted width. 360 * @param int $max_height Optional. Maximum wanted height. 359 361 * @return array First item is the width, the second item is the height. 360 362 */ 361 363 function wp_constrain_dimensions( $current_width, $current_height, $max_width=0, $max_height=0 ) { … … 405 407 $h = $max_height; // Round it up 406 408 } 407 409 410 /** 411 * Constrain image dimensions. 412 * 413 * @since 4.1 414 * 415 * @param array $dimensions The image width and height 416 * @param int $current_width The current width of the image. 417 * @param int $current_height The current height of the image. 418 * @param int $max_width The maximum width permitted. 419 * @param int $max_height The maximum height permitted. 420 */ 408 421 return apply_filters( 'wp_constrain_dimensions', array( $w, $h ), $current_width, $current_height, $max_width, $max_height ); 409 422 } 410 423 … … 531 544 * 532 545 * @since 2.5.0 533 546 * 534 * @param string $file File path. 535 * @param int $width Image width. 536 * @param int $height Image height. 537 * @param bool $crop Optional, default is false. Whether to crop image to specified height and width or resize. 547 * @param string $file File path. 548 * @param int $width Image width. 549 * @param int $height Image height. 550 * @param bool $crop Optional, default is false. Whether to crop image to 551 * specified height and width or resize. 538 552 * @return bool|array False, if no image was created. Metadata array on success. 539 553 */ 540 554 function image_make_intermediate_size( $file, $width, $height, $crop = false ) { … … 576 590 * @since 2.5.0 577 591 * @see add_image_size() 578 592 * 579 * @param int $post_id Attachment ID for image. 580 * @param array|string $size Optional, default is 'thumbnail'. Size of image, either array or string. 593 * @param int $post_id Attachment ID for image. 594 * @param array|string $size Optional, default is 'thumbnail'. Size of image, 595 * either array or string. 581 596 * @return bool|array False on failure or array of file path, width, and height on success. 582 597 */ 583 598 function image_get_intermediate_size($post_id, $size='thumbnail') { … … 631 646 } 632 647 633 648 /** 634 * Get the available image sizes 649 * Get the available image sizes. 650 * 635 651 * @since 3.0.0 636 * @return array Returns a filtered array of image size strings 652 * 653 * @global $_wp_additional_image_sizes 654 * @return array Returns a filtered array of image size strings. 637 655 */ 638 656 function get_intermediate_image_sizes() { 639 657 global $_wp_additional_image_sizes; … … 659 677 * 660 678 * @since 2.5.0 661 679 * 662 * @param int $attachment_id Image attachment ID.663 * @param string $size Optional, default is 'thumbnail'.664 * @param bool $iconOptional, default is false. Whether it is an icon.680 * @param int $attachment_id Image attachment ID. 681 * @param string $size Optional, default is 'thumbnail'. 682 * @param bool $icon Optional, default is false. Whether it is an icon. 665 683 * @return bool|array Returns an array (url, width, height), or false, if no image is available. 666 684 */ 667 685 function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = false) { … … 752 770 * dynamically add/remove itself so as to only filter post thumbnails 753 771 * 754 772 * @since 2.9.0 773 * 755 774 * @param array $attr Attributes including src, class, alt, title 756 775 * @return array 757 776 */ … … 793 812 * 794 813 * @since 2.6.0 795 814 * 796 * @param array $attr {815 * @param array $attr { 797 816 * Attributes of the caption shortcode. 798 817 * 799 818 * @type string $id ID of the div element for the caption. … … 1401 1420 add_shortcode( 'playlist', 'wp_playlist_shortcode' ); 1402 1421 1403 1422 /** 1404 * Provide a No-JS Flash fallback as a last resort for audio / video 1423 * Provide a No-JS Flash fallback as a last resort for audio / video. 1405 1424 * 1406 1425 * @since 3.6.0 1407 1426 * 1408 * @param string $url 1409 * @return string Fallback HTML 1427 * @param string $url The media element URL. 1428 * @return string Fallback HTML. 1410 1429 */ 1411 1430 function wp_mediaelement_fallback( $url ) { 1412 1431 /** … … 1424 1443 * Return a filtered list of WP-supported audio formats. 1425 1444 * 1426 1445 * @since 3.6.0 1427 * @return array 1446 * 1447 * @return array Supported audio formats. 1428 1448 */ 1429 1449 function wp_get_audio_extensions() { 1430 1450 /** … … 1444 1464 * @since 3.9.0 1445 1465 * 1446 1466 * @param WP_Post $attachment The current attachment, provided for context. 1447 * @param string $context The context. Accepts 'edit', 'display'. Default 'display'.1467 * @param string $context Optional. The context. Accepts 'edit', 'display'. Default 'display'. 1448 1468 * @return array Key/value pairs of field keys to labels. 1449 1469 */ 1450 1470 function wp_get_attachment_id3_keys( $attachment, $context = 'display' ) { … … 1481 1501 * 1482 1502 * @since 3.6.0 1483 1503 * 1484 * @param array $attr {1504 * @param array $attr { 1485 1505 * Attributes of the audio shortcode. 1486 1506 * 1487 1507 * @type string $src URL to the source of the audio file. Default empty. … … 1648 1668 add_shortcode( 'audio', 'wp_audio_shortcode' ); 1649 1669 1650 1670 /** 1651 * Return a filtered list of WP-supported video formats 1671 * Return a filtered list of WP-supported video formats. 1652 1672 * 1653 1673 * @since 3.6.0 1654 * @return array 1674 * 1675 * @return array Supported video formats. 1655 1676 */ 1656 1677 function wp_get_video_extensions() { 1657 1678 /** … … 1673 1694 * 1674 1695 * @since 3.6.0 1675 1696 * 1676 * @param array $attr {1697 * @param array $attr { 1677 1698 * Attributes of the shortcode. 1678 1699 * 1679 1700 * @type string $src URL to the source of the video file. Default empty. … … 1893 1914 * Display previous image link that has the same post parent. 1894 1915 * 1895 1916 * @since 2.5.0 1917 * @see adjacent_image_link() 1918 * 1896 1919 * @param string $size Optional, default is 'thumbnail'. Size of image, either array or string. 0 or 'none' will default to post_title or $text; 1897 1920 * @param string $text Optional, default is false. If included, link will reflect $text variable. 1898 1921 * @return string HTML content. … … 1905 1928 * Display next image link that has the same post parent. 1906 1929 * 1907 1930 * @since 2.5.0 1931 * @see adjacent_image_link() 1932 * 1908 1933 * @param string $size Optional, default is 'thumbnail'. Size of image, either array or string. 0 or 'none' will default to post_title or $text; 1909 1934 * @param string $text Optional, default is false. If included, link will reflect $text variable. 1910 1935 * @return string HTML content. … … 1921 1946 * @since 2.5.0 1922 1947 * 1923 1948 * @param bool $prev Optional. Default is true to display previous link, false for next. 1949 * @param str $size Optional. The image size. Default is 'thumbnail'. 1950 * @param bool $text Optional. If string, then will be link text. Default is false. 1951 * @return string The adjacent image link. 1924 1952 */ 1925 1953 function adjacent_image_link($prev = true, $size = 'thumbnail', $text = false) { 1926 1954 $post = get_post(); … … 2009 2037 * @since 3.5.0 2010 2038 * @see get_attachment_taxonomies() 2011 2039 * 2012 * @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default. 2040 * @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 2041 * 'names' is the default. 2013 2042 * @return array The names of all taxonomy of $object_type. 2014 2043 */ 2015 2044 function get_taxonomies_for_attachments( $output = 'names' ) { … … 2031 2060 2032 2061 /** 2033 2062 * Create new GD image resource with transparency support 2034 * @TODO: Deprecate if possible.2035 2063 * 2064 * @todo: Deprecate if possible. 2065 * 2036 2066 * @since 2.9.0 2037 2067 * 2038 * @param int $width Image width2039 * @param int $height Image height 2040 * @return resource resource2068 * @param int $width Image width. 2069 * @param int $height Image height. 2070 * @return resource The GD image resource. 2041 2071 */ 2042 2072 function wp_imagecreatetruecolor($width, $height) { 2043 2073 $img = imagecreatetruecolor($width, $height); … … 2055 2085 * @see WP_Embed::register_handler() 2056 2086 * 2057 2087 * @global WP_Embed $wp_embed 2058 * @param string $id 2059 * @param string $regex 2060 * @param callable $callback 2061 * @param int $priority 2088 * @param string $id An internal ID/name for the handler. Needs to be unique. 2089 * @param string $regex The regex that will be used to see if this handler should be used for a URL. 2090 * @param callback $callback The callback function that will be called if the regex is matched. 2091 * @param int $priority Optional. Used to specify the order in which the registered handlers will 2092 * be tested (default: 10). 2062 2093 */ 2063 2094 function wp_embed_register_handler( $id, $regex, $callback, $priority = 10 ) { 2064 2095 global $wp_embed; … … 2072 2103 * @see WP_Embed::unregister_handler() 2073 2104 * 2074 2105 * @global WP_Embed $wp_embed 2075 * @param string $id 2076 * @param int $priority 2106 * @param string $id The handler ID that should be removed. 2107 * @param int $priority Optional. The priority of the handler to be removed (default: 10). 2077 2108 */ 2078 2109 function wp_embed_unregister_handler( $id, $priority = 10 ) { 2079 2110 global $wp_embed; … … 2121 2152 * Based on a supplied width/height example, return the biggest possible dimensions based on the max width/height. 2122 2153 * 2123 2154 * @since 2.9.0 2155 * @see wp_constrain_dimensions() 2124 2156 * 2125 * @param int $example_width The width of an example embed.2157 * @param int $example_width The width of an example embed. 2126 2158 * @param int $example_height The height of an example embed. 2127 * @param int $max_width The maximum allowed width.2128 * @param int $max_height The maximum allowed height.2159 * @param int $max_width The maximum allowed width. 2160 * @param int $max_height The maximum allowed height. 2129 2161 * @return array The maximum possible width and height based on the example ratio. 2130 2162 */ 2131 2163 function wp_expand_dimensions( $example_width, $example_height, $max_width, $max_height ) { … … 2143 2175 * @since 2.9.0 2144 2176 * @see WP_oEmbed 2145 2177 * 2146 * @param string $url The URL that should be embedded.2147 * @param array $args Additional arguments and parameters.2178 * @param string $url The URL that should be embedded. 2179 * @param array $args Additional arguments and parameters. 2148 2180 * @return false|string False on failure or the embed HTML on success. 2149 2181 */ 2150 2182 function wp_oembed_get( $url, $args = '' ) { … … 2159 2191 * @since 2.9.0 2160 2192 * @see WP_oEmbed 2161 2193 * 2162 * @param string $formatThe format of URL that this provider can handle. You can use asterisks as wildcards.2163 * @param string $provider The URL to the oEmbed provider.2164 * @param boolean $regex Whether the $format parameter is in a regex format.2194 * @param string $format The format of URL that this provider can handle. You can use asterisks as wildcards. 2195 * @param string $provider The URL to the oEmbed provider. 2196 * @param boolean $regex Whether the $format parameter is in a regex format. 2165 2197 */ 2166 2198 function wp_oembed_add_provider( $format, $provider, $regex = false ) { 2167 2199 require_once( ABSPATH . WPINC . '/class-oembed.php' ); … … 2181 2213 * @see WP_oEmbed 2182 2214 * 2183 2215 * @param string $format The URL format for the oEmbed provider to remove. 2216 * @return bool Was the provider removed successfully? 2184 2217 */ 2185 2218 function wp_oembed_remove_provider( $format ) { 2186 2219 require_once( ABSPATH . WPINC . '/class-oembed.php' ); … … 2206 2239 * it hasn't, then it will load the embeds library. 2207 2240 * 2208 2241 * @since 2.9.0 2242 * @see wp_embed_register_handler() 2209 2243 */ 2210 2244 function wp_maybe_load_embeds() { 2211 2245 /** … … 2250 2284 * @see WP_Embed::register_handler() 2251 2285 * @see WP_Embed::shortcode() 2252 2286 * 2253 * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.2254 * @param array $attrEmbed attributes.2255 * @param string $url The original URL that was matched by the regex.2256 * @param array $rawattr The original unmodified attributes.2287 * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}. 2288 * @param array $attr Embed attributes. 2289 * @param string $url The original URL that was matched by the regex. 2290 * @param array $rawattr The original unmodified attributes. 2257 2291 * @return string The embed HTML. 2258 2292 */ 2259 2293 function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) { … … 2296 2330 function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) { 2297 2331 global $wp_embed; 2298 2332 $embed = $wp_embed->autoembed( "https://youtube.com/watch?v={$matches[2]}" ); 2333 2299 2334 /** 2300 2335 * Filter the YoutTube embed output. 2301 2336 * … … 2343 2378 * 2344 2379 * @since 3.6.0 2345 2380 * 2346 * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.2347 * @param array $attrEmbed attributes.2348 * @param string $url The original URL that was matched by the regex.2349 * @param array $rawattr The original unmodified attributes.2381 * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}. 2382 * @param array $attr Embed attributes. 2383 * @param string $url The original URL that was matched by the regex. 2384 * @param array $rawattr The original unmodified attributes. 2350 2385 * @return string The embed HTML. 2351 2386 */ 2352 2387 function wp_embed_handler_video( $matches, $attr, $url, $rawattr ) { … … 2417 2452 * Returns a WP_Image_Editor instance and loads file into it. 2418 2453 * 2419 2454 * @since 3.5.0 2420 * @ access public2455 * @see _wp_image_editor_choose() 2421 2456 * 2422 * @param string $path Path to file to load2423 * @param array $args Additional data. Accepts { 'mime_type'=>string, 'methods'=>{string, string, ...} }2424 * @return WP_Image_Editor|WP_Error 2457 * @param string $path Path to the file to load. 2458 * @param array $args Additional data. Accepts { 'mime_type'=>string, 'methods'=>{string, string, ...} }. 2459 * @return WP_Image_Editor|WP_Error The WP_Image_Editor object if successful, an WP_Error object otherwise. 2425 2460 */ 2426 2461 function wp_get_image_editor( $path, $args = array() ) { 2427 2462 $args['path'] = $path; … … 2454 2489 * Tests whether there is an editor that supports a given mime type or methods. 2455 2490 * 2456 2491 * @since 3.5.0 2457 * @ access public2492 * @see _wp_image_editor_choose() 2458 2493 * 2459 2494 * @param string|array $args Array of requirements. Accepts { 'mime_type'=>string, 'methods'=>{string, string, ...} } 2460 * @return boolean true if an eligible editor is found; false otherwise 2495 * @return boolean true if an eligible editor is found; false otherwise. 2461 2496 */ 2462 2497 function wp_image_editor_supports( $args = array() ) { 2463 2498 return (bool) _wp_image_editor_choose( $args ); … … 2513 2548 * Prints default plupload arguments. 2514 2549 * 2515 2550 * @since 3.4.0 2551 * 2552 * @global $wp_scripts 2516 2553 */ 2517 2554 function wp_plupload_default_settings() { 2518 2555 global $wp_scripts; … … 2783 2820 * all media JS APIs. 2784 2821 * 2785 2822 * @since 3.5.0 2823 * 2824 * @global $content_width 2825 * @global $wpdb 2826 * @global $wp_locale 2827 * @param array $args { 2828 * @type int|WP_Post A post object or ID. 2829 * } 2830 * @return array List of media view settings. 2786 2831 */ 2787 2832 function wp_enqueue_media( $args = array() ) { 2788 2833 … … 3126 3171 * @since 3.6.0 3127 3172 * 3128 3173 * @param string $content A string which might contain media data. 3129 * @param array $types array of media types: 'audio', 'video', 'object', 'embed', or 'iframe' 3130 * @return array A list of found HTML media embeds 3174 * @param array $types Optional. An array of media types: 'audio', 'video', 'object', 'embed', 3175 * or 'iframe'. Defaults to null. 3176 * @return array A list of found HTML media embeds. 3131 3177 */ 3132 3178 function get_media_embedded_in_content( $content, $types = null ) { 3133 3179 $html = array(); … … 3155 3201 * @param int|WP_Post $post Optional. Post ID or object. 3156 3202 * @param bool $html Whether to return HTML or data in the array. 3157 3203 * @return array A list of arrays, each containing gallery data and srcs parsed 3158 * 3204 * from the expanded shortcode. 3159 3205 */ 3160 3206 function get_post_galleries( $post, $html = true ) { 3161 3207 if ( ! $post = get_post( $post ) ) … … 3205 3251 * @since 3.6.0 3206 3252 * 3207 3253 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. 3208 * @param bool $html Whether to return HTML or data.3254 * @param bool $html Optional. Whether to return HTML or data. Default is true. 3209 3255 * @return string|array Gallery data and srcs parsed from the expanded shortcode. 3210 3256 */ 3211 3257 function get_post_gallery( $post = 0, $html = true ) { … … 3231 3277 * 3232 3278 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. 3233 3279 * @return array A list of lists, each containing image srcs parsed. 3234 * 3280 * from an expanded shortcode 3235 3281 */ 3236 3282 function get_post_galleries_images( $post = 0 ) { 3237 3283 $galleries = get_post_galleries( $post, false ); … … 3282 3328 * @since 4.0.0 3283 3329 * 3284 3330 * @global wpdb $wpdb WordPress database abstraction object. 3285 *3286 3331 * @param string $url The URL to resolve. 3287 3332 * @return int The found post ID. 3288 3333 */ … … 3312 3357 * @since 4.0.0 3313 3358 * 3314 3359 * @global $wp_version 3315 *3316 3360 * @return array The relevant CSS file URLs. 3317 3361 */ 3318 3362 function wpview_media_sandbox_styles() {