Andrew Ozz
fd11ef9c45
Responsive images:
...
- Check if wp_get_attachment_metadata() has returned an array to prevent errors when using SVGs.
- Only add the srcset attribute if there will be a sizes attribute.
- Better filter names.
- Some more inline docs fixes.
Props jaspermdegroot.
See #34430 .
Built from https://develop.svn.wordpress.org/trunk@35419
git-svn-id: http://core.svn.wordpress.org/trunk@35383 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-28 20:01:26 +00:00
Andrew Ozz
61d21cc0d9
Responsive images:
...
- Introduce `wp_calculate_image_srcset()` that replaces `wp_get_attachment_image_srcset_array()` and is used as lower level function for retrieving the srcset data as array.
- Use the new function when generating `srcset` and `sizes` on the front-end. This is faster as no (other) image API functions are used.
- Change the `wp_get_attachment_image_srcset()`. Now it is meant for use in templates and is no longer used in core.
- A few logic fixes and improvements.
- Some names changed to be (hopefully) more descriptive.
- Fixed/updated tests.
Props joemcgill, jaspermdegroot, azaozz.
See #34430 .
Built from https://develop.svn.wordpress.org/trunk@35412
git-svn-id: http://core.svn.wordpress.org/trunk@35376 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-28 05:41:24 +00:00
Sergey Biryukov
1acf9e9e49
After [35402], don't unnecessary run `wp_get_attachment_metadata()`, `wp_get_attachment_image_srcset()`, and `wp_get_attachment_image_sizes()` in `wp_img_add_srcset_and_sizes()`.
...
See #34379 .
Built from https://develop.svn.wordpress.org/trunk@35405
git-svn-id: http://core.svn.wordpress.org/trunk@35369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-26 18:42:24 +00:00
Sergey Biryukov
1e59e53dd2
After [35402], don't unnecessary run `wp_get_attachment_image_srcset()` and `wp_get_attachment_image_sizes()` in `wp_get_attachment_image()` if `srcset` is passed as an argument.
...
See #34379 .
Built from https://develop.svn.wordpress.org/trunk@35404
git-svn-id: http://core.svn.wordpress.org/trunk@35368 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-26 18:40:24 +00:00
Sergey Biryukov
f5d0260e4d
Remove assignments from conditions in `wp_get_attachment_image()` and `wp_img_add_srcset_and_sizes()`.
...
See #34379 .
Built from https://develop.svn.wordpress.org/trunk@35402
git-svn-id: http://core.svn.wordpress.org/trunk@35366 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-26 16:29:26 +00:00
Sergey Biryukov
64a79eeffa
Docs: After [34453], correct inline comments in `wp_get_attachment_image_sizes()`.
...
Props jaspermdegroot.
Fixes #34453 .
Built from https://develop.svn.wordpress.org/trunk@35401
git-svn-id: http://core.svn.wordpress.org/trunk@35365 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-26 16:17:25 +00:00
Andrew Ozz
902f0f1a98
Responsive Images: fix typo in r35358.
...
Props aduth.
See #34341 .
Built from https://develop.svn.wordpress.org/trunk@35378
git-svn-id: http://core.svn.wordpress.org/trunk@35342 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-23 17:38:25 +00:00
Andrew Ozz
dfc2412be1
Responsive Images: limit the size of images included in `srcset` attributes. Introduce `max_srcset_image_width` filter to adjust the limit.
...
Props joemcgill.
Fixes #34341 .
Built from https://develop.svn.wordpress.org/trunk@35358
git-svn-id: http://core.svn.wordpress.org/trunk@35324 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-22 19:31:25 +00:00
Scott Taylor
318ad90a22
Media: in `wp_get_attachment_image_sizes()`, to streamline and for performance:
...
* Change the 3rd arg from `args` to `width`
* Change `wp_image_sizes_args` filter to `wp_get_attachment_image_sizes`
Updates unit tests.
Props joemcgill.
Fixes #34379 .
Built from https://develop.svn.wordpress.org/trunk@35355
git-svn-id: http://core.svn.wordpress.org/trunk@35321 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-22 16:46:24 +00:00
Drew Jaynes
81524f3bfc
Filesystem: Following the introduction of the `KB|MB|GB|TB_IN_BYTES` constants in [35286], use them in various places in core.
...
Props sudar.
Fixes #22405 .
Built from https://develop.svn.wordpress.org/trunk@35325
git-svn-id: http://core.svn.wordpress.org/trunk@35291 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-21 14:03:25 +00:00
Drew Jaynes
3686b78448
Media: Introduce the `image_get_intermediate_size` filter to its like-named function, making it possible to manipulate returned intermedia image size data.
...
Covers both the default and meaningful short-circuit return cases. Also adds a hash notation to the return documentation in the DocBlock.
Props A5hleyRich, DH-Shredder, wonderboymusic.
Fixes #34124 .
Built from https://develop.svn.wordpress.org/trunk@35289
git-svn-id: http://core.svn.wordpress.org/trunk@35255 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-20 07:24:27 +00:00
Scott Taylor
443ce28304
Media: in `wp_get_attachment_image_sizes()`, ensure that `$img_width` exists when the image does not.
...
Props kraftbj.
See #33641 .
Built from https://develop.svn.wordpress.org/trunk@35250
git-svn-id: http://core.svn.wordpress.org/trunk@35216 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-17 22:12:24 +00:00
Drew Jaynes
d4711aff8a
Docs: Fix a typo in an inline comment in `wp_get_attachment_image_srcset_array()`.
...
Props neoxx.
Fixes #34319 .
Built from https://develop.svn.wordpress.org/trunk@35210
git-svn-id: http://core.svn.wordpress.org/trunk@35176 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-15 20:52:24 +00:00
Scott Taylor
affe1ab5ad
Media: avoid "divide by zero" in `wp_get_attachment_image_srcset_array()`.
...
Fixes #34238 .
Built from https://develop.svn.wordpress.org/trunk@35081
git-svn-id: http://core.svn.wordpress.org/trunk@35046 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 21:00:26 +00:00
Drew Jaynes
2d677edb1f
Docs: The `$size` parameter for the `get_image_tag` hook also accepts an array.
...
See #34257 . See [35038].
Built from https://develop.svn.wordpress.org/trunk@35078
git-svn-id: http://core.svn.wordpress.org/trunk@35043 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 17:11:24 +00:00
Drew Jaynes
36ef44735d
Docs: The `$size` parameter for the `get_image_tag_class` hook also accepts an array.
...
See #34257 . See [35037].
Built from https://develop.svn.wordpress.org/trunk@35077
git-svn-id: http://core.svn.wordpress.org/trunk@35042 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 17:09:25 +00:00
Drew Jaynes
d4fe129e1a
Docs: Adjust the order of 'width' and 'height' (for consistency) for the `$crop` parameter documentation in `image_make_intermediate_size()`.
...
Props jaspermdegroot.
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35054
git-svn-id: http://core.svn.wordpress.org/trunk@35019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 16:06:24 +00:00
Drew Jaynes
8b26e5debc
Docs: Adjust the order of 'width' and 'height' (for consistency) for the `$crop` parameter documentation in `image_resize_dimensions()`.
...
Also similarly adjusts the `$crop` parameter description in the corresponding `image_resize_dimensions` hook doc.
Props jaspermdegroot.
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35053
git-svn-id: http://core.svn.wordpress.org/trunk@35018 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 16:02:24 +00:00
Drew Jaynes
e0529ebdb5
Docs: Adjust the order of 'width' and 'height' (for consistency) for the `$crop` parameter documentation in `set_post_thumbnail_size()`.
...
Props jaspermdegroot.
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35052
git-svn-id: http://core.svn.wordpress.org/trunk@35017 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 16:00:26 +00:00
Drew Jaynes
771248a1f3
Docs: Adjust the order of 'width' and 'height' (for consistency) for the `$crop` parameter documentation in `add_image_size()`.
...
Props jaspermdegroot.
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35051
git-svn-id: http://core.svn.wordpress.org/trunk@35016 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:59:25 +00:00
Drew Jaynes
d0a392a34c
Docs: Adjust documentation for the `$size` parameter in `adjacent_image_link()` to clarify the required order of width and height values when passing an array.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35049
git-svn-id: http://core.svn.wordpress.org/trunk@35014 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:53:25 +00:00
Drew Jaynes
81f67bae13
Docs: Adjust documentation for the `$size` parameter in `next_image_link()` to clarify the required order of width and height values when passing an array.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35048
git-svn-id: http://core.svn.wordpress.org/trunk@35013 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:50:24 +00:00
Drew Jaynes
141b096f6d
Docs: Adjust documentation for the `$size` parameter in `previous_image_link()` to clarify the required order of width and height values when passing an array.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35047
git-svn-id: http://core.svn.wordpress.org/trunk@35012 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:48:25 +00:00
Drew Jaynes
1571907571
Docs: Normalize spacing in the `$attr` hash notation for `gallery_shortcode()` following [35045].
...
See #34257 . See #32246 .
Built from https://develop.svn.wordpress.org/trunk@35046
git-svn-id: http://core.svn.wordpress.org/trunk@35011 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:46:24 +00:00
Drew Jaynes
e4f9e334ea
Docs: Adjust documentation for the `$size` argument in `gallery_shortcode` to clarify the required order of width and height values when passing an array.
...
Also adds the `array` type to the argument documentation.
Props jaspermdegroot.
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35045
git-svn-id: http://core.svn.wordpress.org/trunk@35010 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:43:25 +00:00
Drew Jaynes
9d5d27c26d
Docs: Adjust documentation for the `$size` parameter in `wp_get_attachment_image_url()` to clarify the required order of width and height values when passing an array.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35044
git-svn-id: http://core.svn.wordpress.org/trunk@35009 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:39:25 +00:00
Drew Jaynes
987fe676a9
Docs: Adjust documentation for the `$size` parameter in the `wp_get_attachment_image_attributes` hook doc to clarify the required order of width and height values when an array is passed.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35043
git-svn-id: http://core.svn.wordpress.org/trunk@35008 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:38:24 +00:00
Drew Jaynes
5631df0151
Docs: Adjust documentation for the `$size` parameter in `wp_get_attachment_image()` to clarify the required order of width and height values when passing an array.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35042
git-svn-id: http://core.svn.wordpress.org/trunk@35007 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:36:24 +00:00
Drew Jaynes
c02b132fcc
Docs: Adjust documentation for the `$size` parameter in the `wp_get_attachment_image_src` hook doc to clarify the required order of width and height values when an array is passed.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35041
git-svn-id: http://core.svn.wordpress.org/trunk@35006 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:34:24 +00:00
Drew Jaynes
8f3f5dba35
Docs: Adjust documentation for the `$size` parameter in `wp_get_attachment_image_src()` to clarify the required order of width and height values when passing an array.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35040
git-svn-id: http://core.svn.wordpress.org/trunk@35005 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:31:24 +00:00
Drew Jaynes
50fd2488f4
Docs: Adjust documentation for the `$size` parameter in `image_get_intermediate_size()` to clarify the required order of width and height values when passing an array.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35039
git-svn-id: http://core.svn.wordpress.org/trunk@35004 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:29:24 +00:00
Drew Jaynes
5a0eaa17de
Docs: Adjust documentation for the `$size` parameter in the `get_image_tag` hook doc to clarify the required order of width and height values when an array is passed.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35038
git-svn-id: http://core.svn.wordpress.org/trunk@35003 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:27:25 +00:00
Drew Jaynes
698b5f6880
Docs: Adjust documentation for the `$size` parameter in the `get_image_tag_class` hook doc to clarify the required order of width and height values when an array is passed.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35037
git-svn-id: http://core.svn.wordpress.org/trunk@35002 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:26:25 +00:00
Drew Jaynes
71932de1f5
Docs: Adjust documentation for the `$size` parameter in `get_image_tag()` to clarify the required order of width and height values when passing an array.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35036
git-svn-id: http://core.svn.wordpress.org/trunk@35001 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:21:25 +00:00
Drew Jaynes
3f8aaf753a
Docs: Adjust documentation for the `$size` parameter in the `image_downside` hook doc to clarify the required order of width and height values when an array is passed.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35035
git-svn-id: http://core.svn.wordpress.org/trunk@35000 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:20:23 +00:00
Drew Jaynes
45174a8996
Docs: Adjust documentation for the `$size` parameter in `image_downsize()` to clarify the required order of width and height values when passing an array.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35034
git-svn-id: http://core.svn.wordpress.org/trunk@34999 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:18:24 +00:00
Drew Jaynes
7c25ad0613
Docs: Adjust documentation for the `$size` parameter in `image_constrain_size_for_editor()` to clarify the required order of width and height values when passing an array.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35033
git-svn-id: http://core.svn.wordpress.org/trunk@34998 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:16:24 +00:00
Drew Jaynes
1e2caf6712
Docs: Update an inline comment in `wp_get_attachment_image_sizes()`, which came in as part of the Responsive Images merge in [34855].
...
Props joemcgill.
See #33641 .
Built from https://develop.svn.wordpress.org/trunk@34876
git-svn-id: http://core.svn.wordpress.org/trunk@34841 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-06 17:47:24 +00:00
Scott Taylor
99be7beda0
Merge the Responsive Images feature plugin into core, initial commit. See: https://github.com/ResponsiveImagesCG/wp-tevko-responsive-images/
...
New functions in `media.php`:
* `wp_get_attachment_image_srcset_array()` - Returns an array of image candidate string data used to build a `srcset` value for an attachment given an `$attachement_id` and `$size`.
* `wp_get_attachment_image_srcset()` - Returns the `srcset` value for an attachment given an `$attachement_id` and `$size`.
* `wp_get_attachment_image_sizes()` - Returns the `sizes` value for an attachment given an `$attachement_id` and `$size` and optional arguments used to alter its output.
* `wp_make_content_images_responsive()` - A display filter for adding `srcset` and `sizes` to images embedded in content.
* `wp_img_add_srcset_and_sizes()` - A utility function used by `wp_make_content_images_responsive()` to add `srcset` and `sizes` to a single `<img>` element.
Modifies existing core functions:
* Modify `wp_get_attachment_image()` so the HTML returned for an image includes `srcset` and `sizes`.
* Modify `get_media_embedded_in_content()` (sup, 3.6 leftover) by adding `<img>` to the list of accepted tags that can be matched in content. This is used in `wp_make_content_images_responsive()` to find all of the images embedded in content before passing them off to `wp_img_add_srcset_and_sizes()`.
Tests:
* Add a new factory method to `WP_UnitTest_Factory_For_Attachment` named `create_upload_object()`
* Adds unit tests
* Updates unit tests
Props joemcgill, tevko, jaspermdegroot, mdmcginn, barryceelen, peterwilsoncc, fsylum, wonderboymusic, chriscoyier, benjaminpick, jrfnl, #12kingkool68, janhenckens, ryanmarkel, side777, ryelle, wturrell, micahmills, mattbagwell, coliff, DrewAPicture.
See #33641 .
Built from https://develop.svn.wordpress.org/trunk@34855
git-svn-id: http://core.svn.wordpress.org/trunk@34820 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-06 04:59:24 +00:00
Scott Taylor
d96fb9def9
Embeds: move some functions from `media.php` to a new file, `embed-functions.php`, via `svn cp`
...
See #32522 .
Built from https://develop.svn.wordpress.org/trunk@34851
git-svn-id: http://core.svn.wordpress.org/trunk@34816 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-06 03:59:24 +00:00
Scott Taylor
6cde1a05cb
After [34629], use `$size_class` instead of `$size`.
...
See #32093 .
Built from https://develop.svn.wordpress.org/trunk@34657
git-svn-id: http://core.svn.wordpress.org/trunk@34621 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-28 02:50:24 +00:00
Scott Taylor
1b6ed5cbb7
Add `size-$size` class to `<img>` in `wp_get_attachment_image()`.
...
Fixes #32093 .
Built from https://develop.svn.wordpress.org/trunk@34629
git-svn-id: http://core.svn.wordpress.org/trunk@34593 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-27 17:54:27 +00:00
John Blackbourn
aa35e473f7
`callback` is not a valid type in PHP, PSR-5, or phpDocumentor. `callable` should be used instead.
...
Fixes #34032
Built from https://develop.svn.wordpress.org/trunk@34566
git-svn-id: http://core.svn.wordpress.org/trunk@34530 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-25 23:58:25 +00:00
Scott Taylor
8cc5a142e4
Media Modal: move the translation strings for `insertIntoPost` and `uploadedToThisPost` to the `get_post_type_labels()` array as `insert_into_item` and `uploaded_to_this_item`.
...
Props flixos90.
Fixes #33616 .
Built from https://develop.svn.wordpress.org/trunk@34472
git-svn-id: http://core.svn.wordpress.org/trunk@34436 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 03:22:24 +00:00
Scott Taylor
d165b25920
Include fourth array parameter in return value doc block for `wp_get_attachment_image_src()`.
...
Props kadamwhite.
Fixes #33905 .
Built from https://develop.svn.wordpress.org/trunk@34470
git-svn-id: http://core.svn.wordpress.org/trunk@34434 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 03:14:24 +00:00
Scott Taylor
2ddc1d2f3a
Media: Add a new function, `wp_get_attachment_image_url()`, which is a shortcut for `wp_get_attachment_image_src()` - same function signature, but returns just the URL based on `$size`.
...
Adds unit test.
Props dipesh.kakadiya, swissspidy, sebastian.pisula.
Fixes #33878 .
Built from https://develop.svn.wordpress.org/trunk@34372
git-svn-id: http://core.svn.wordpress.org/trunk@34336 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-22 04:13:27 +00:00
Drew Jaynes
bbae198372
Docs: Add a more complete return description for the array of data (or false) returned by `image_downsize()`.
...
If not short-circuited via the `image_downsize` boolean filter, `image_downsize()` returns an array of data including the image URL, width, height, and whether the image size is intermediate, in that order. Otherwise, it returns false.
Fixes #30636 .
Built from https://develop.svn.wordpress.org/trunk@34362
git-svn-id: http://core.svn.wordpress.org/trunk@34326 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-21 10:22:26 +00:00
Scott Taylor
1f3dce8c75
Media: Ensure that HTML5 captions apply the `'img_caption_shortcode_width'`.
...
Props joemcgill.
Fixes #31053 .
Built from https://develop.svn.wordpress.org/trunk@34261
git-svn-id: http://core.svn.wordpress.org/trunk@34225 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-17 06:04:24 +00:00
Scott Taylor
ad0eb9c442
Media: In `wp_prepare_attachment_for_js()`, don't call `file_exists()` and `filesize()` to retrieve `$bytes` if the data is already present in `$meta`. This is how the same code in `attachment_submitbox_metadata()` already works.
...
Props polevaultweb.
Fixes #33214 .
Built from https://develop.svn.wordpress.org/trunk@34258
git-svn-id: http://core.svn.wordpress.org/trunk@34222 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-17 05:03:24 +00:00
Scott Taylor
191400f9e6
Don't ever use the `guid` value when retrieving URLs for media, use `wp_get_attachment_url()`. Use `get_attached_file()` for path to file.
...
Fixes #33386 .
Built from https://develop.svn.wordpress.org/trunk@34163
git-svn-id: http://core.svn.wordpress.org/trunk@34131 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-15 02:50:25 +00:00