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
..
2016-05-13 18:41:31 +00:00
2016-07-12 11:18:30 +00:00
2016-07-17 16:47:39 +00:00
2016-03-18 20:43:26 +00:00
2016-02-23 16:55:27 +00:00
2016-07-15 03:16:30 +00:00
2016-03-08 17:15:27 +00:00
2016-06-14 05:30:28 +00:00
2016-07-12 11:45:29 +00:00
2016-07-06 17:08:31 +00:00
2016-07-06 12:40:29 +00:00
2016-05-23 18:59:27 +00:00
2016-05-19 00:06:28 +00:00
2016-07-06 12:40:29 +00:00
2016-05-22 18:24:28 +00:00
2016-05-27 17:16:27 +00:00
2016-07-06 12:40:29 +00:00
2016-05-22 18:50:28 +00:00
2016-06-30 01:02:29 +00:00
2016-07-06 12:40:29 +00:00
2016-07-06 12:40:29 +00:00
2016-05-22 18:50:28 +00:00
2016-07-13 15:51:28 +00:00
2016-05-22 18:50:28 +00:00
2016-06-15 18:52:28 +00:00
2016-07-13 15:44:29 +00:00
2016-06-06 03:24:29 +00:00
2016-07-06 12:40:29 +00:00
2016-03-22 17:22:29 +00:00
2016-05-22 18:50:28 +00:00
2016-04-29 15:47:27 +00:00
2016-06-06 15:18:31 +00:00
2016-05-22 18:50:28 +00:00
2016-05-22 18:50:28 +00:00
2016-07-12 11:18:30 +00:00
2016-07-10 00:51:30 +00:00
2016-07-07 14:27:38 +00:00
2016-01-17 15:00:27 +00:00
2016-05-22 18:10:29 +00:00
2016-07-10 00:51:30 +00:00
2016-06-28 22:44:30 +00:00
2016-05-22 18:10:29 +00:00
2016-05-22 18:10:29 +00:00
2016-07-06 05:59:28 +00:00
2016-05-23 18:54:27 +00:00
2016-07-14 13:29:31 +00:00
2016-07-10 00:51:30 +00:00
2016-05-22 17:39:28 +00:00
2016-05-22 18:15:28 +00:00
2016-05-22 18:15:28 +00:00
2016-06-10 04:50:33 +00:00
2016-05-22 18:15:28 +00:00
2016-05-22 18:15:28 +00:00
2016-07-06 17:51:30 +00:00
2016-05-22 18:15:28 +00:00
2016-07-08 14:37:30 +00:00
2016-07-08 14:37:30 +00:00
2016-05-22 18:15:28 +00:00
2016-06-28 11:53:28 +00:00
2016-06-26 14:26:29 +00:00
2016-05-23 18:54:27 +00:00
2016-07-07 15:52:28 +00:00
2016-06-29 19:35:28 +00:00
2016-05-25 19:22:27 +00:00
2016-07-13 15:24:28 +00:00
2016-05-23 18:54:27 +00:00
2016-05-22 18:15:28 +00:00
2016-05-13 18:41:31 +00:00
2016-07-17 23:30:31 +00:00
2016-06-29 22:08:28 +00:00
2016-07-17 16:33:30 +00:00
2016-07-09 11:49:29 +00:00
2016-07-17 16:15:34 +00:00
2016-07-04 09:58:28 +00:00
2016-05-22 18:15:28 +00:00
2016-07-06 12:40:29 +00:00
2016-05-13 18:41:31 +00:00
2016-04-30 22:36:28 +00:00
2016-06-06 21:51:28 +00:00
2016-07-17 16:15:34 +00:00
2016-05-23 18:59:27 +00:00
2016-03-14 22:39:26 +00:00
2016-07-06 12:40:29 +00:00
2016-05-22 18:50:28 +00:00
2016-07-08 23:56:32 +00:00
2016-07-13 14:05:29 +00:00
2016-06-19 12:51:27 +00:00
2016-07-06 12:40:29 +00:00
2016-05-22 18:50:28 +00:00
2016-07-08 14:37:30 +00:00
2016-07-13 12:54:28 +00:00
2016-07-08 14:37:30 +00:00
2016-07-06 12:40:29 +00:00
2016-07-05 16:16:57 +00:00
2016-06-10 04:50:33 +00:00
2016-05-22 18:50:28 +00:00
2016-07-13 17:04:28 +00:00
2016-07-06 12:40:29 +00:00
2016-07-12 13:21:29 +00:00
2016-07-06 12:40:29 +00:00
2016-07-06 12:40:29 +00:00
2016-07-12 11:32:28 +00:00
2016-05-23 19:01:27 +00:00
2016-06-30 17:02:30 +00:00
2016-07-06 12:40:29 +00:00
2016-07-06 12:40:29 +00:00
2016-07-08 18:36:30 +00:00
2016-06-28 11:53:28 +00:00
2016-07-05 11:32:29 +00:00
2016-07-18 02:14:29 +00:00
2016-07-13 04:46:28 +00:00
2016-07-13 16:04:29 +00:00
2016-07-06 12:40:29 +00:00
2016-07-06 12:40:29 +00:00
2016-07-06 12:40:29 +00:00
2016-07-06 12:40:29 +00:00
2016-06-29 19:00:28 +00:00
2016-06-06 15:18:31 +00:00
2016-06-20 08:26:29 +00:00
2016-07-06 12:40:29 +00:00
2016-07-06 12:40:29 +00:00
2016-07-13 18:04:28 +00:00
2016-07-13 19:22:28 +00:00
2016-07-06 12:40:29 +00:00
2016-06-29 17:28:28 +00:00
2016-07-17 16:05:31 +00:00
2016-07-06 12:40:29 +00:00
2016-07-06 12:40:29 +00:00
2016-07-06 12:40:29 +00:00
2016-06-29 03:02:07 +00:00
2016-06-29 15:16:29 +00:00
2016-05-23 19:02:28 +00:00
2016-07-06 12:40:29 +00:00
2016-07-06 12:40:29 +00:00
2016-07-17 15:32:30 +00:00
2016-05-23 19:02:28 +00:00
2016-06-26 14:26:29 +00:00
2016-07-17 16:15:34 +00:00
2016-05-22 18:50:28 +00:00
2016-05-22 18:50:28 +00:00
2016-07-06 12:40:29 +00:00
2016-05-25 19:36:28 +00:00
2016-07-06 12:40:29 +00:00
2016-05-22 18:50:28 +00:00
2016-07-18 02:14:29 +00:00
2016-05-23 19:02:28 +00:00
2016-07-06 12:40:29 +00:00
2016-05-23 19:02:28 +00:00