WordPress/wp-includes
Joe McGill 28a132dfee Media: Prevent image_get_intermediate_size() from returning cropped images.
When `$size` is passed to `image_get_intermediate_size()` as an array of width
and height values and an exact image size matching those values isn't available,
the function loops through the available attachment sizes and returns the
smallest image larger than the requested dimensions with the same aspect ratio.

The aspect ratio check is skipped for the 'thumbnail' size to provide a fallback
for small sizes when no other image option is available. This resulted in a poor
selection when the size requested was smaller than the 'thumbnail' dimensions
but a larger size matching the requested ratio existed.

This refactors the internals of `image_get_intermediate_size()` to ensure the
'thumbnail' size is only returned as a fallback to small sizes once all other
options have been considered, and makes the control flow easier to follow.

This also introduces a new helper function, `wp_image_matches_ratio()` for
testing whether the aspect ratios of two sets of dimensions match. This function
is also now used in `wp_calculate_image_srcset()` during the selection process.

Props flixos, joemcgill.
Fixes #34384, #34980.
Built from https://develop.svn.wordpress.org/trunk@38086


git-svn-id: http://core.svn.wordpress.org/trunk@38027 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-18 02:14:29 +00:00
..
certificates
css Toolbar: Allow 0 as a value for the tabindex property of a menu item. 2016-07-12 11:18:30 +00:00
customize I18N: Combine duplicate "Menu Locations" and "Menu Options" strings. 2016-07-17 16:47:39 +00:00
fonts
ID3
images
js Media: Always add alt attributes to images inserted from URLs 2016-07-15 03:16:30 +00:00
pomo
random_compat
Requests HTTP API: Update Requests. 2016-06-14 05:30:28 +00:00
rest-api Text Changes: Unify/merge two more permission error messages. 2016-07-12 11:45:29 +00:00
SimplePie
Text
theme-compat Embeds: Don't print the HTML for a featured image if a post has no featured image. 2016-07-06 17:08:31 +00:00
widgets Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
admin-bar.php Docs: Apply inline @see tags to hooks referenced in DocBlocks in a variety of wp-includes/* files. 2016-05-23 18:59:27 +00:00
atomlib.php
author-template.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
bookmark-template.php Docs: Standardize filter docs in wp-includes/bookmark-template.php to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:24:28 +00:00
bookmark.php Docs: Improve formatting in the DocBlock for sanitize_bookmark_field(). 2016-05-27 17:16:27 +00:00
cache.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
canonical.php Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:50:28 +00:00
capabilities.php Introduce an expanded meta registration API. 2016-06-30 01:02:29 +00:00
category-template.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
category.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
class-feed.php Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:50:28 +00:00
class-http.php HTTP API: Pass proxy settings to Requests. 2016-07-13 15:51:28 +00:00
class-IXR.php Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:50:28 +00:00
class-json.php
class-oembed.php Embeds: In WP_oEmbed::get_provider() and WP_oEmbed::get_html(), parse the $args string to an array, as we treat it as an array later. 2016-06-15 18:52:28 +00:00
class-phpass.php
class-phpmailer.php
class-pop3.php
class-requests.php HTTP API: Update Requests. 2016-07-13 15:44:29 +00:00
class-simplepie.php Autoload: Introduce shim for SPL autoloading. 2016-06-06 03:24:29 +00:00
class-smtp.php Upgrade PHPMailer from 5.2.10 to 5.2.14. 2015-12-24 01:59:26 +00:00
class-snoopy.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
class-walker-category-dropdown.php
class-walker-category.php Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:50:28 +00:00
class-walker-comment.php
class-walker-nav-menu.php Nav Menus: Move the Walker_Nav_Menu class to its own file. 2016-06-06 15:18:31 +00:00
class-walker-page-dropdown.php Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:50:28 +00:00
class-walker-page.php Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:50:28 +00:00
class-wp-admin-bar.php Toolbar: Allow 0 as a value for the tabindex property of a menu item. 2016-07-12 11:18:30 +00:00
class-wp-ajax-response.php Docs: Standardize capitalization of Ajax throughout core documentation per the core spelling guide. 2016-07-10 00:51:30 +00:00
class-wp-comment-query.php Comments: Cache results of SELECT FOUND_ROWS() query. 2016-07-07 14:27:38 +00:00
class-wp-comment.php
class-wp-customize-control.php Docs: Standardize filter docs in the Customizer classes to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:10:29 +00:00
class-wp-customize-manager.php Docs: Standardize capitalization of Ajax throughout core documentation per the core spelling guide. 2016-07-10 00:51:30 +00:00
class-wp-customize-nav-menus.php Customize: Link "widget areas" to widgets panel in menu locations section description. 2016-06-28 22:44:30 +00:00
class-wp-customize-panel.php Docs: Standardize filter docs in the Customizer classes to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:10:29 +00:00
class-wp-customize-section.php Docs: Standardize filter docs in the Customizer classes to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:10:29 +00:00
class-wp-customize-setting.php Customize: Ensure that WP_Customize_Setting::value() can return a previewed value for aggregated multidimensionals. 2016-07-06 05:59:28 +00:00
class-wp-customize-widgets.php Docs: Apply inline @see tags to hooks referenced in DocBlocks for core classes. 2016-05-23 18:54:27 +00:00
class-wp-editor.php Editor: Enqueue the wp-embed script to fix embed previews inside the media modal. 2016-07-14 13:29:31 +00:00
class-wp-embed.php Docs: Standardize capitalization of Ajax throughout core documentation per the core spelling guide. 2016-07-10 00:51:30 +00:00
class-wp-error.php
class-wp-http-cookie.php Docs: Standardize filter docs in core classes in wp-includes/* to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:15:28 +00:00
class-wp-http-curl.php Docs: Standardize filter docs in core classes in wp-includes/* to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:15:28 +00:00
class-wp-http-encoding.php DOCS: Replace HTTP links with HTTPS. 2016-06-10 04:50:33 +00:00
class-wp-http-ixr-client.php Docs: Standardize filter docs in core classes in wp-includes/* to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:15:28 +00:00
class-wp-http-proxy.php Docs: Standardize filter docs in core classes in wp-includes/* to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:15:28 +00:00
class-wp-http-requests-response.php HTTP API: Switch back to returning an array. 2016-07-06 17:51:30 +00:00
class-wp-http-response.php
class-wp-http-streams.php Docs: Standardize filter docs in core classes in wp-includes/* to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:15:28 +00:00
class-wp-image-editor-gd.php Bootstrap: Enhance core's memory limit handling. 2016-07-08 14:37:30 +00:00
class-wp-image-editor-imagick.php Bootstrap: Enhance core's memory limit handling. 2016-07-08 14:37:30 +00:00
class-wp-image-editor.php Docs: Standardize filter docs in core classes in wp-includes/* to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:15:28 +00:00
class-wp-locale.php I18N: Move the WP_Locale class to its own file. 2016-06-28 11:53:28 +00:00
class-wp-meta-query.php Multisite: Change WP_Network id property to an integer. 2016-06-26 14:26:29 +00:00
class-wp-metadata-lazyloader.php Docs: Apply inline @see tags to hooks referenced in DocBlocks for core classes. 2016-05-23 18:54:27 +00:00
class-wp-network-query.php Multisite: Don't store max_num_pages in WP_Network_Query query cache. 2016-07-07 15:52:28 +00:00
class-wp-network.php Docs: Supplement a changelog entry in the DocBlock for the $id property in WP_Network. 2016-06-29 19:35:28 +00:00
class-wp-oembed-controller.php Docs: Add missing @access tags to methods in WP_oEmbed_Controller. 2016-05-25 19:22:27 +00:00
class-wp-post-type.php Docs: Add and clarify changelog entries for elements that can now accept, use, or return WP_Post_Type objects. 2016-07-13 15:24:28 +00:00
class-wp-post.php
class-wp-rewrite.php Docs: Apply inline @see tags to hooks referenced in DocBlocks for core classes. 2016-05-23 18:54:27 +00:00
class-wp-role.php Docs: Standardize filter docs in core classes in wp-includes/* to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:15:28 +00:00
class-wp-roles.php
class-wp-site-query.php Multisite: Correct default values for orderby and order in WP_Site_Query::__construct(). 2016-07-17 23:30:31 +00:00
class-wp-site.php Multisite: Revert property type changes in WP_Site. 2016-06-29 22:08:28 +00:00
class-wp-tax-query.php Taxonomy: Correct WP_Error usage in WP_Tax_Query::clean_query() and WP_Tax_Query::transform_query(). 2016-07-17 16:33:30 +00:00
class-wp-term-query.php Taxonomy: Remove an unnecessary double assignment in WP_Term_Query::get_terms(). 2016-07-09 11:49:29 +00:00
class-wp-term.php Text Changes: Add a full stop to "Invalid taxonomy" and "Invalid term ID" strings, for consistency with similar post-related messages. 2016-07-17 16:15:34 +00:00
class-wp-theme.php Themes: After [37287], add deprecated theme features to the tag list in WP_Theme::translate_header(). 2016-07-04 09:58:28 +00:00
class-wp-user-query.php Docs: Standardize filter docs in core classes in wp-includes/* to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:15:28 +00:00
class-wp-user.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
class-wp-walker.php
class-wp-widget-factory.php
class-wp-widget.php Widgets: Revert [37425] and [37427]. 2016-06-06 21:51:28 +00:00
class-wp-xmlrpc-server.php Text Changes: Add a full stop to "Invalid taxonomy" and "Invalid term ID" strings, for consistency with similar post-related messages. 2016-07-17 16:15:34 +00:00
class-wp.php Docs: Apply inline @see tags to hooks referenced in DocBlocks in a variety of wp-includes/* files. 2016-05-23 18:59:27 +00:00
class.wp-dependencies.php
class.wp-scripts.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
class.wp-styles.php Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:50:28 +00:00
comment-template.php Docs: Fix a typo in an inline hook reference in the DocBlock for comment_form(). 2016-07-08 23:56:32 +00:00
comment.php Comments: Include comment_content with html and without in blacklist_keys comparison. 2016-07-13 14:05:29 +00:00
compat.php Menus: Fix _wp_expand_nav_menu_post_data() for PHP 5.2. 2016-06-19 12:51:27 +00:00
cron.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
date.php Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:50:28 +00:00
default-constants.php Bootstrap: Enhance core's memory limit handling. 2016-07-08 14:37:30 +00:00
default-filters.php Resource Hints: Increase priority of wp_resource_hints() so hints get printed before scripts and styles. 2016-07-13 12:54:28 +00:00
default-widgets.php
deprecated.php Bootstrap: Enhance core's memory limit handling. 2016-07-08 14:37:30 +00:00
embed-template.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
embed.php Embeds: After [37745], check if a featured image exists before attaching an event listener. 2016-07-05 16:16:57 +00:00
feed-atom-comments.php DOCS: Replace HTTP links with HTTPS. 2016-06-10 04:50:33 +00:00
feed-atom.php Feeds: <comments> is optional in RSS2, so don't include it when comments aren't present or open. Same for <wfw:commentRss> and <slash:comments> 2015-11-04 17:47:25 +00:00
feed-rdf.php
feed-rss2-comments.php
feed-rss2.php Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:50:28 +00:00
feed-rss.php
feed.php Docs: Add an initial @since version to wp-includes/feed.php. 2016-07-13 17:04:28 +00:00
formatting.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
functions.php Meta: Add a missing @since param for wp_object_type_exists(). 2016-07-12 13:21:29 +00:00
functions.wp-scripts.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
functions.wp-styles.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
general-template.php Resource Hints: Remove schemes from dns-prefetch resource hint outputs. 2016-07-12 11:32:28 +00:00
http.php Docs: Apply inline @see tags to hooks referenced in DocBlocks in a variety of wp-includes/* files. 2016-05-23 19:01:27 +00:00
kses.php Docs: Add changelog entries to the hook doc for the safe_style_css filter denoting recent CSS attribute additions. 2016-06-30 17:02:30 +00:00
l10n.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
link-template.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
load.php Bootstrap: Make wp_is_ini_value_changeable() compatible with PHP 5.2.6 - 5.2.17. 2016-07-08 18:36:30 +00:00
locale.php I18N: Move the WP_Locale class to its own file. 2016-06-28 11:53:28 +00:00
media-template.php Customize: Add a RTL version of "browser.png" for the site icon preview. 2016-07-05 11:32:29 +00:00
media.php Media: Prevent image_get_intermediate_size() from returning cropped images. 2016-07-18 02:14:29 +00:00
meta.php Meta: Ensure filters are backwards compatible for pre-4.6 style meta registration. 2016-07-13 04:46:28 +00:00
ms-blogs.php Docs: Update the default value for the optional $args parameter in get_networks() following [38042]. 2016-07-13 16:04:29 +00:00
ms-default-constants.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
ms-default-filters.php
ms-deprecated.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
ms-files.php if is a statment, not a function. 2015-06-16 20:01:25 +00:00
ms-functions.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
ms-load.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
ms-settings.php Multisite: Fire the ms_loaded action after multisite's bootstrap has finished. 2016-06-29 19:00:28 +00:00
nav-menu-template.php Nav Menus: Move the Walker_Nav_Menu class to its own file. 2016-06-06 15:18:31 +00:00
nav-menu.php Docs: Improve the summaries and return descriptions for get_registered_nav_menus() and get_nav_menu_locations(). 2016-06-20 08:26:29 +00:00
option.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
pluggable-deprecated.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
pluggable.php Mail: Improve handling of UTF-8 address headers. 2016-07-13 18:04:28 +00:00
plugin.php Docs: Update a cross-reference in the DocBlock for wp_register_plugin_realpath() from plugin_basename() to wp_normalize_path(). 2016-07-13 19:22:28 +00:00
post-formats.php
post-template.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
post-thumbnail-template.php Post Thumbnails: Add helper functions for attachment captions. 2016-06-29 17:28:28 +00:00
post.php I18N: Combine two duplicate "Invalid post type" strings. 2016-07-17 16:05:31 +00:00
query.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
registration-functions.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
registration.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
rest-api.php REST API: Include a refreshed nonce in a X-WP-Nonce header when responding to an authenticated request. 2016-06-29 03:02:07 +00:00
revision.php Text Changes: Unify permission error messages. 2016-06-29 15:16:29 +00:00
rewrite.php Docs: Apply inline @see tags to hooks referenced in DocBlocks in a variety of wp-includes/* files. 2016-05-23 19:02:28 +00:00
rss-functions.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
rss.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
script-loader.php Import: Enhance accessibility on the Import screen. 2016-07-17 15:32:30 +00:00
session.php Docs: Apply inline @see tags to hooks referenced in DocBlocks in a variety of wp-includes/* files. 2016-05-23 19:02:28 +00:00
shortcodes.php Multisite: Change WP_Network id property to an integer. 2016-06-26 14:26:29 +00:00
taxonomy.php Text Changes: Add a full stop to "Invalid taxonomy" and "Invalid term ID" strings, for consistency with similar post-related messages. 2016-07-17 16:15:34 +00:00
template-loader.php Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:50:28 +00:00
template.php Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:50:28 +00:00
theme.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
update.php Upgrade: Allow update checks on upgrader_process_complete to be run during Ajax requests. 2016-05-25 19:36:28 +00:00
user.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
vars.php Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP. 2016-05-22 18:50:28 +00:00
version.php Media: Prevent image_get_intermediate_size() from returning cropped images. 2016-07-18 02:14:29 +00:00
widgets.php Docs: Apply inline @see tags to hooks referenced in DocBlocks in a variety of wp-includes/* files. 2016-05-23 19:02:28 +00:00
wlwmanifest.xml
wp-db.php Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core. 2016-07-06 12:40:29 +00:00
wp-diff.php Docs: Apply inline @see tags to hooks referenced in DocBlocks in a variety of wp-includes/* files. 2016-05-23 19:02:28 +00:00