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
Andrew Ozz
5987caeecc
After [45538]: fix a WPCS fix and make couple of var names consistent.
...
See #40439 .
Built from https://develop.svn.wordpress.org/trunk@45539
git-svn-id: http://core.svn.wordpress.org/trunk@45350 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-06-15 01:32:53 +00:00
Andrew Ozz
05302bd054
Save progress of intermediate image creation after upload. First run.
...
- Introduces `wp_get_missing_image_subsizes()` and `wp_update_image_subsizes()` to generate image sub-sizes that are missing or were not created after the upload.
- Adds a way to display errors that happened while creating sub-sizes.
- Introduces `wp_create_image_subsizes()` intended for use after an image was uploaded. It saves/updates the image metadata immediately after each sub-size is created. This fixes the (long standing) problem when some of the sub-size image files were created but there was a timeout or an error and the metadata was not saved. Until now such uploads were considered "failed" which usually resulted in the user trying to upload the same image again, creating even more "orphan" image files.
Note that the patch also includes some unrelated WPCS fixes.
Props mikeschroder, azaozz.
See #40439 .
Built from https://develop.svn.wordpress.org/trunk@45538
git-svn-id: http://core.svn.wordpress.org/trunk@45349 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-06-15 01:02:52 +00:00
Aaron Jorbin
71cf332e65
Replace usages of basename() with wp_basename() in order to support multibyte filenames
...
This is focused on the pieces of code that touch media files and the tests that support them. `basename` isn't multibyte compatible out of the box. See http://php.net/basename and https://bugs.php.net/bug.php?id=62119 .
See #43170 .
Props Viper007Bond.
Built from https://develop.svn.wordpress.org/trunk@44785
git-svn-id: http://core.svn.wordpress.org/trunk@44617 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-03-01 20:58:52 +00:00
Gary Pendergast
4f861b9548
Coding Standards: Fix the Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace
violations.
...
See #45934 .
Built from https://develop.svn.wordpress.org/trunk@44566
git-svn-id: http://core.svn.wordpress.org/trunk@44397 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-11 06:40:50 +00:00
desrosj
f29dfe7b6d
Docs: Update since
tag for new intermediate_image_sizes_advanced
filter parameter.
...
Originally added in [42407].
Fixes #42745 .
Built from https://develop.svn.wordpress.org/trunk@44385
git-svn-id: http://core.svn.wordpress.org/trunk@44215 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-03 17:47:49 +00:00
Gary Pendergast
56c162fbc9
Coding Standards: Upgrade WPCS to 1.0.0
...
WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.
This change includes three notable additions:
- Multiline function calls must now put each parameter on a new line.
- Auto-formatting files is now part of the `grunt precommit` script.
- Auto-fixable coding standards issues will now cause Travis failures.
Fixes #44600 .
Built from https://develop.svn.wordpress.org/trunk@43571
git-svn-id: http://core.svn.wordpress.org/trunk@43400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-08-17 01:51:36 +00:00
Sergey Biryukov
ff314fd156
Media: Pass EXIF data to the wp_read_image_metadata
filter.
...
Props desrosj.
Fixes #43624 .
Built from https://develop.svn.wordpress.org/trunk@42879
git-svn-id: http://core.svn.wordpress.org/trunk@42709 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-03-25 20:45:29 +00:00
Sergey Biryukov
079cfd60a9
Media: In wp_read_image_metadata()
, rename $sourceImageType
variable to $image_type
to match coding standards.
...
See #43624 .
Built from https://develop.svn.wordpress.org/trunk@42878
git-svn-id: http://core.svn.wordpress.org/trunk@42708 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-03-25 20:41:29 +00:00
Mike Schroder
51b0a3cd28
Media: Correctly allow changing PDF thumbnail crop value.
...
Corrects logic that keeping plugins from setting crop value of intermediate image sizes for rendered PDFs.
Adds test.
Props leemon, SergeyBiryukov, chetan200891, birgire.
Fixes #43226 .
Built from https://develop.svn.wordpress.org/trunk@42792
git-svn-id: http://core.svn.wordpress.org/trunk@42622 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-03-07 01:19:31 +00:00
Sergey Biryukov
5596017878
Media: Recognize .ico
files as displayable images on PHP 5.3+ and allow attachment meta data to be generated for them.
...
Props remyvv, Guido07111975.
Fixes #43458 .
Built from https://develop.svn.wordpress.org/trunk@42780
git-svn-id: http://core.svn.wordpress.org/trunk@42610 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-03-05 01:03:31 +00:00
Sergey Biryukov
35653f0432
Media: Bring consistency to getimagesize()
error suppression.
...
Props chasewg, joemcgill, jeremyfelt.
Fixes #42480 .
Built from https://develop.svn.wordpress.org/trunk@42449
git-svn-id: http://core.svn.wordpress.org/trunk@42279 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-01-15 19:44:47 +00:00