Sergey Biryukov
d32aa67e80
Docs: Update syntax for multi-line comment in wp_generate_attachment_metadata()
per the documentation standards.
...
Follow-up to [23766], [25968], [35554], [51162].
Props hellofromTonya.
Fixes #52603 .
Built from https://develop.svn.wordpress.org/trunk@51166
git-svn-id: http://core.svn.wordpress.org/trunk@50775 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-06-15 19:10:58 +00:00
Sergey Biryukov
4803207ba1
Media: Make sure wp_generate_attachment_metadata()
always returns an array.
...
This matches the documentation for the filter of the same name.
Previously, the function could return `false` for an audio or video attachment that does not exist in the local filesystem.
Props Chouby, SergeyBiryukov.
Fixes #52603 .
Built from https://develop.svn.wordpress.org/trunk@51162
git-svn-id: http://core.svn.wordpress.org/trunk@50771 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-06-15 16:52:56 +00:00
Sergey Biryukov
16c42e467d
Media: Move retrieving WebP image size information into wp_getimagesize()
.
...
Remove `_wp_get_image_size()`.
Follow-up to [50146], [50810], [50814].
Props johnjamesjacoby.
See #35725 .
Built from https://develop.svn.wordpress.org/trunk@50815
git-svn-id: http://core.svn.wordpress.org/trunk@50424 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-05 18:47:57 +00:00
Adam Silverstein
524030edfa
Images: enable WebP support.
...
Add support for uploading, editing and saving WebP images when supported by the server.
Add 'image/webp' to supported mime types. Correctly identify WebP images and sizes even when PHP doesn't support WebP. Resize uploaded WebP files (when supported) and use for front end markup.
Props markoheijne, blobfolio, Clorith, joemcgill, atjn, desrosj, spacedmonkey, marylauc, mikeschroder, hellofromtonya, flixos90.
Fixes #35725 .
Built from https://develop.svn.wordpress.org/trunk@50810
git-svn-id: http://core.svn.wordpress.org/trunk@50419 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-04 14:44:58 +00:00
whyisjake
471fc1e913
Media: Pass the appropriate reference into wp_getimagesize
.
...
With changes that were introduced in [49889] the second parameter for getimagesize() function is expecting a a reference.
Previously, most calls did not pass the 2nd param, and as a result, we are getting unexpected results.
This was only a problem with applications that are using a custom stream wrapper, and the image contained EXIF data.
For more see:
* https://github.com/humanmade/S3-Uploads/issues/496
* https://github.com/aws/aws-sdk-php/issues/1923
Fixes #52826 .
Props terriann, SergeyBiryukov, Mista-Flo, hellofromTonya, rinatkhaziev, whyisjake.
Built from https://develop.svn.wordpress.org/trunk@50552
git-svn-id: http://core.svn.wordpress.org/trunk@50165 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-03-19 00:01:03 +00:00
antpb
b566631d5e
Media: Consistency in logic to pass wp_getimagesize()
tests.
...
Previously, we used `DIR_TESTDATA` to determine if a test should skip a newly silenced error in `wp_getimagesize()`.
We are now using `WP_RUN_CORE_TESTS` instead for consistency.
Props hellofromTonya, SergeyBiryukov.
See #49889 .
Built from https://develop.svn.wordpress.org/trunk@50170
git-svn-id: http://core.svn.wordpress.org/trunk@49849 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-02-02 21:36:03 +00:00
antpb
f80e5d0919
Media: Avoid suppressing errors when using getimagesize()
.
...
Previously, all logic utilizing `getimagesize()` was supressing errors making it difficult to debug usage of the function.
A new `wp_getimagesize()` function has been added to allow the errors to no longer be suppressed when `WP_DEBUG` is enabled.
Props Howdy_McGee, SergeyBiryukov, mukesh27, davidbaumwald, noisysocks, hellofromTonya.
Fixes #49889 .
Built from https://develop.svn.wordpress.org/trunk@50146
git-svn-id: http://core.svn.wordpress.org/trunk@49825 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-02-02 16:53:04 +00:00
John Blackbourn
b59c0f307b
Docs: Corrections and improvements to types used in various docblocks.
...
See #51800 , #52217
Built from https://develop.svn.wordpress.org/trunk@49936
git-svn-id: http://core.svn.wordpress.org/trunk@49635 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-05 17:16:11 +00:00
Sergey Biryukov
37662df05e
Docs: In various @return
tags, list the expected type first, instead of false
or WP_Error
.
...
Follow-up to [46696], [47060], [49926], [49927].
See #51800 .
Built from https://develop.svn.wordpress.org/trunk@49929
git-svn-id: http://core.svn.wordpress.org/trunk@49628 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-04 17:18:04 +00:00
John Blackbourn
dfe1f9b322
Docs: Promote many bool
types to true
or false
where only that value is used.
...
See #51800
Built from https://develop.svn.wordpress.org/trunk@49927
git-svn-id: http://core.svn.wordpress.org/trunk@49626 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-03 22:04:04 +00:00
John Blackbourn
53da9208dd
Docs: Various docblock corrections particularly relating to boolean types.
...
See #51800
Built from https://develop.svn.wordpress.org/trunk@49926
git-svn-id: http://core.svn.wordpress.org/trunk@49625 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-03 21:57:09 +00:00
John Blackbourn
aba2165aae
Media: Standardise the description for image size parameters.
...
This brings continuity to all the image related functions and filters which accept or pass a size parameter.
Props dilipbheda, johnbillion
Fixes #47364
Built from https://develop.svn.wordpress.org/trunk@49021
git-svn-id: http://core.svn.wordpress.org/trunk@48783 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-09-20 16:23:07 +00:00
John Blackbourn
0b2e31a7f8
Docs: Inline documentation improvements for media related functions and hooks.
...
See #47364 , #50768
Built from https://develop.svn.wordpress.org/trunk@49020
git-svn-id: http://core.svn.wordpress.org/trunk@48782 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-09-20 15:55:10 +00:00
John Blackbourn
43b11121de
Media: Correct some types for attachment ID parameters passed to functions and filters.
...
See #47364 , #50768
Built from https://develop.svn.wordpress.org/trunk@49017
git-svn-id: http://core.svn.wordpress.org/trunk@48779 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-09-20 14:05:05 +00:00
Sergey Biryukov
af523447f4
Media: Make the is_gd_image()
function available on front end.
...
This avoids a fatal error if a plugin calls image creation or editing functions like `wp_imagecreatetruecolor()` outside of the admin.
Follow-up to [48798]
Props BackuPs.
Fixes #51174 . See #50833 .
Built from https://develop.svn.wordpress.org/trunk@48905
git-svn-id: http://core.svn.wordpress.org/trunk@48667 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-08-28 16:45:06 +00:00
Sergey Biryukov
54184bf872
Docs: Fix typo in the $image
parameter description in is_gd_image()
.
...
Follow-up to [48798].
See #50833 .
Built from https://develop.svn.wordpress.org/trunk@48799
git-svn-id: http://core.svn.wordpress.org/trunk@48561 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-08-16 14:02:03 +00:00
Sergey Biryukov
12c8f0e678
Code Modernization: Introduce is_gd_image()
to check for PHP 8 GdImage
object instances.
...
In PHP 8, the GD extension uses `GdImage` objects instead of resources for its underlying data structures.
This updates the existing `is_resource()` calls for image resources in core to accomodate for `GdImage` instances as well.
Props ayeshrajans, jrf.
Fixes #50833 .
Built from https://develop.svn.wordpress.org/trunk@48798
git-svn-id: http://core.svn.wordpress.org/trunk@48560 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-08-16 13:33:09 +00:00
John Blackbourn
57a3f803ae
Docs: First pass at some inline docs fixes mostly made by PHPCBF.
...
See #49572 , #50744
Built from https://develop.svn.wordpress.org/trunk@48586
git-svn-id: http://core.svn.wordpress.org/trunk@48348 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-23 20:01:04 +00:00
John Blackbourn
0bf9b04c53
Docs: Various formatting improvements to inline docblocks.
...
See #49572
Built from https://develop.svn.wordpress.org/trunk@48574
git-svn-id: http://core.svn.wordpress.org/trunk@48336 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-23 00:52:05 +00:00
John Blackbourn
c3f787b8ff
Docs: Miscellaneous docblock corrections.
...
See #49572
Built from https://develop.svn.wordpress.org/trunk@48508
git-svn-id: http://core.svn.wordpress.org/trunk@48270 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-18 22:11:02 +00:00
John Blackbourn
7004afe4f4
Docs: Various docblock corrections and improvements.
...
See #49572
Built from https://develop.svn.wordpress.org/trunk@47461
git-svn-id: http://core.svn.wordpress.org/trunk@47248 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-03-16 18:40:07 +00:00
Sergey Biryukov
6b2c63031c
Coding Standards: Rename $d
parameter in various date/time functions to $format
for clarity.
...
See #49222 .
Built from https://develop.svn.wordpress.org/trunk@47287
git-svn-id: http://core.svn.wordpress.org/trunk@47087 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-14 00:07:07 +00:00
Sergey Biryukov
641c632b0c
Coding Standards: Use Yoda conditions where appropriate.
...
See #49222 .
Built from https://develop.svn.wordpress.org/trunk@47219
git-svn-id: http://core.svn.wordpress.org/trunk@47019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-09 16:55:09 +00:00
Sergey Biryukov
001ffe81fb
Docs: Improve inline comments per the documentation standards.
...
Includes minor code layout fixes for better readability.
See #48303 .
Built from https://develop.svn.wordpress.org/trunk@47122
git-svn-id: http://core.svn.wordpress.org/trunk@46922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-29 00:45:18 +00:00
Sergey Biryukov
053a9cd5b8
Docs: Improve comments in some wp-admin
files per the documentation standards.
...
Props passoniate.
Fixes #49215 , #49216 .
Built from https://develop.svn.wordpress.org/trunk@47084
git-svn-id: http://core.svn.wordpress.org/trunk@46884 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-18 00:54:04 +00:00
Andrew Ozz
135e608b46
Upload: Exclude PNG images from scaling after uploading. Fixes a case where resizing a very large PNG may create a scaled image that has smaller dimensions but larger file size than the original.
...
Fixes #48736 .
Built from https://develop.svn.wordpress.org/trunk@46809
git-svn-id: http://core.svn.wordpress.org/trunk@46609 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-12-01 18:26:05 +00:00
Andrew Ozz
60c2966222
Upload: When an image was scaled because it is larger than the big image threshold, use the originally uploaded image's dimensions in wp_get_missing_image_subsizes()
. Fixes an edge case/inconsistent behaviour when a registered image sub-size is also larger than the big image threshold.
...
Props desrosj, azaozz.
Fixes #48518 for trunk.
Built from https://develop.svn.wordpress.org/trunk@46677
git-svn-id: http://core.svn.wordpress.org/trunk@46477 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-07 18:51:02 +00:00
Andrew Ozz
f9e81c83d5
Media: Remove the variable number (from the big image threshold value) when generating file names for scaled images. This makes it easier to "calculate" the full size file name from the name of an intermediate size image.
...
Props ianmjones, azaozz.
Fixes #48453 for trunk.
Built from https://develop.svn.wordpress.org/trunk@46658
git-svn-id: http://core.svn.wordpress.org/trunk@46458 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-05 20:53:03 +00:00
Andrew Ozz
43ed67661a
Upload: Ensure the new image meta is always saved before starting post-processing of an uploaded image, even if there was an error while scaling or rotating it.
...
See #48472 .
Built from https://develop.svn.wordpress.org/trunk@46651
git-svn-id: http://core.svn.wordpress.org/trunk@46451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-04 17:07:03 +00:00
Sergey Biryukov
8b76312eb3
Docs: Correct some array hash notations added in [46644].
...
See #48303 .
Built from https://develop.svn.wordpress.org/trunk@46647
git-svn-id: http://core.svn.wordpress.org/trunk@46447 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-04 09:37:02 +00:00
John Blackbourn
b3d6acd6a4
Docs: Fix some incorrect return tags in docblocks.
...
See #48303
Built from https://develop.svn.wordpress.org/trunk@46644
git-svn-id: http://core.svn.wordpress.org/trunk@46444 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-03 22:23:01 +00:00
Sergey Biryukov
3d76b537d6
Docs: Add @since
tag for the $context
parameter added to wp_generate_attachment_metadata
filter in [46621].
...
See #48472 .
Built from https://develop.svn.wordpress.org/trunk@46622
git-svn-id: http://core.svn.wordpress.org/trunk@46419 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-31 00:13:01 +00:00
Andrew Ozz
ed651b17a4
Upload:
...
- Run the `wp_generate_attachment_metadata` filter at the end in `wp_update_image_subsizes()` when new metadata was generated and additional image sub-sizes were created.
- Add another arg in the `wp_generate_attachment_metadata` filter for additional context.
- Fix inline docs and ensure the new image meta is always saved before starting post-processing.
Fixes #48472 for trunk.
Built from https://develop.svn.wordpress.org/trunk@46621
git-svn-id: http://core.svn.wordpress.org/trunk@46418 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-30 21:10:04 +00:00
Andrew Ozz
e1560cd1e0
Media/Upload: When the users upload big images and WordPress creates a scaled image to use as the largest size, append scaled-
to the file names of the scaled images to make them easier to recognize.
...
Props kraftbj, azaozz.
Fixes #48304 .
Built from https://develop.svn.wordpress.org/trunk@46565
git-svn-id: http://core.svn.wordpress.org/trunk@46362 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-21 21:43:04 +00:00
Andrew Ozz
1940cf7d54
Media: Do not store error messages in the image meta. The initial idea was to (be able to) display these errors in the UI but it wasn't implemented as these errors are mostly helpful for low-level bedugging.
...
Fixes #40439 .
Built from https://develop.svn.wordpress.org/trunk@46507
git-svn-id: http://core.svn.wordpress.org/trunk@46304 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-14 20:05:01 +00:00
Mike Schroder
66c8085fc4
Media: Update fallback previews to support _wp_make_subsizes()
...
Allows fallback previews (PDF by default, in core) to save image meta
after each size is generated to allow for resuming, and make sizes
immediately available.
Props azaozz, antpb, progremzion, mikeschroder.
See #48111 .
Built from https://develop.svn.wordpress.org/trunk@46459
git-svn-id: http://core.svn.wordpress.org/trunk@46257 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-11 07:54:03 +00:00
Andrew Ozz
f793398e4f
Upload: Set custom header with the attachment ID for all uploads from media_handle_upload()
. Let the REST API endpoint set it separately.
...
Props timothyblynjacobs.
Fixes #48200 .
Built from https://develop.svn.wordpress.org/trunk@46421
git-svn-id: http://core.svn.wordpress.org/trunk@46219 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-07 15:30:02 +00:00
Sergey Biryukov
60617d471b
Docs: Add missing documentation for the first parameter of the big_image_size_threshold
filter.
...
Props dkarfa, desrosj, earnjam.
Fixes #48214 .
Built from https://develop.svn.wordpress.org/trunk@46398
git-svn-id: http://core.svn.wordpress.org/trunk@46197 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-05 01:30:58 +00:00
Andrew Ozz
ff225c8bfc
Upload: Fix the method used to create image sub-sizes when uploading fails with a PHP fatal error. Use a custom header to send the new attachment post ID even in HTTP 500 responses instead of an upload reference sent by the client. Also add another cap check and remove the action when deleting an attachment post during a failed upload cleanup.
...
Props timothyblynjacobs, clorith, azaozz.
Fixes #48200 .
Built from https://develop.svn.wordpress.org/trunk@46382
git-svn-id: http://core.svn.wordpress.org/trunk@46181 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-03 21:02:00 +00:00
Sergey Biryukov
44c3cefb24
Docs: Fix typo in wp_get_missing_image_subsizes()
DocBlock.
...
Props david.binda.
Fixes #48179 .
Built from https://develop.svn.wordpress.org/trunk@46368
git-svn-id: http://core.svn.wordpress.org/trunk@46167 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-01 01:19:57 +00:00
Andrew Ozz
38e6958698
Media: Move wp_get_original_image_path()
to wp-content/post.php
to make it easier to access from plugins.
...
Props pbiron.
See #47873 .
Built from https://develop.svn.wordpress.org/trunk@46353
git-svn-id: http://core.svn.wordpress.org/trunk@46152 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-30 16:28:59 +00:00
Sergey Biryukov
a879bcb1c6
Code Modernization: Remove a workaround for IMAGETYPE_ICO
in file_is_displayable_image()
.
...
The `IMAGETYPE_ICO` constant was introduced in PHP 5.3, so no longer needs a workaround.
Props jrf.
See #48074 .
Built from https://develop.svn.wordpress.org/trunk@46217
git-svn-id: http://core.svn.wordpress.org/trunk@46029 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-20 22:18:59 +00:00
Andrew Ozz
29ea4c6a4c
Media/Upload: rotate images on upload according to EXIF Orientation.
...
Props msaggiorato, wpdavis, markoheijnen, dhuyvetter, msaggiorato, n7studios, triplejumper12, pbiron, mikeschroder, joemcgill, azaozz.
Fixes #14459 .
Built from https://develop.svn.wordpress.org/trunk@46202
git-svn-id: http://core.svn.wordpress.org/trunk@46014 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-20 18:21:57 +00:00
Andrew Ozz
dc8349ba0a
Media: Add handling for "BIG" images. When the users upload a big image, typically a photo, scale it down to make it suitable for web use. Then use the scaled image as the "full" size, and keep the originally uploaded image for creating high quality sub-sizes in the future and in case the users want to download it later.
...
Introduces `wp_get_original_image_path()` that retrieves the path to the originally uploaded image in all cases, and `big_image_size_threshold` filter to set the pixel value above which images will be scaled. The same value is used as max-width and max-height when scaling.
See #47873 .
Built from https://develop.svn.wordpress.org/trunk@46076
git-svn-id: http://core.svn.wordpress.org/trunk@45888 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-07 01:07:55 +00:00
Andrew Ozz
e313498193
Uploads: After an image is uploaded and PHP times out or runs out of memory during post-processing (the server response is HTTP 500 error), try to resize it three more times. Then, if all attempts fail, do a cleanup of any sub-sizes that may have been created and show an error message asking the user to scale the image and upload it again.
...
See #47872 .
Built from https://develop.svn.wordpress.org/trunk@45934
git-svn-id: http://core.svn.wordpress.org/trunk@45745 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-04 01:11:54 +00:00
Sergey Biryukov
3d12c4b6d8
Docs: Fix typo in _wp_make_subsizes()
DocBlock.
...
Props itowhid06.
Fixes #47913 . See #40439 .
Built from https://develop.svn.wordpress.org/trunk@45871
git-svn-id: http://core.svn.wordpress.org/trunk@45682 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-21 16:23:56 +00:00
Andrew Ozz
5eba5381e6
Media: Sort the new sizes array by priority when creating image sub-sizes.
...
See #40439 .
Built from https://develop.svn.wordpress.org/trunk@45645
git-svn-id: http://core.svn.wordpress.org/trunk@45456 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-16 21:48:56 +00:00
Gary Pendergast
abcbee954f
Coding Standards: Fix instances of WordPress.PHP.NoSilencedErrors.Discouraged
.
...
Noteable changes:
- The `magic_quotes_runtime` and `magic_quotes_sybase` settings were removed in PHP 5.4, so no longer need to be set.
- Some functions that use external libraries can generate errors that can't be tested for, so are globally allowed to silence errors.
- Quite a few functions would cause errors if `safe_mode` was set. This setting was removed in PHP 5.4.
- Only a handful of `header()` calls needed corresponding `headers_sent()` checks for unit tests to pass, but more may need to be added as the nightlies builds are tested.
See #46732 .
Built from https://develop.svn.wordpress.org/trunk@45611
git-svn-id: http://core.svn.wordpress.org/trunk@45422 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-09 05:45:58 +00:00
Andrew Ozz
88ffa41ee3
Media: Ignore errors coming from image_resize_dimensions()
when creating sub-sizes (for now). It returns false
when the requested size is larger than the original image and should be skipped. This triggers new WP_Error
in WP_Image_Editor::resize()
.
...
See #40439 .
Built from https://develop.svn.wordpress.org/trunk@45543
git-svn-id: http://core.svn.wordpress.org/trunk@45354 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-06-16 01:33:51 +00:00
Andrew Ozz
da7839dc45
After [45538]: fix another WPCS "strict comparison" fix.
...
Props birgire.
See #40439 .
Built from https://develop.svn.wordpress.org/trunk@45540
git-svn-id: http://core.svn.wordpress.org/trunk@45351 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-06-15 16:24:52 +00:00