Commit dcb6aa4
Fix client-side media file naming (#75817)
* Fix client-side media file naming
The original filename was stripped and replaced with a generic
prefix (e.g., "image.jpeg", "document.pdf") during client-side
media processing. Two issues caused this:
1. convertBlobToFile() used instanceof File which fails for
cross-realm File objects from the iframe where the block
editor canvas renders. Now checks for the name property
as a fallback to preserve the original filename.
2. generateThumbnails() referenced attachment.media_filename
which doesn't exist. The REST API field is "filename".
Thumbnails now correctly use the server-provided filename.
* re-enable client sifde media as naming issue is resolved
* expect client side media to be enabled
* complete removal of disabling shim
* Fix client-side media scaled image handling
Upload the original file unscaled, then create and sideload
the -scaled version after sub-sizes. This matches WordPress
core's server-side behavior: original_image metadata is set
correctly, sub-sizes derive names from the original, and
wp_unique_filename no longer adds -1 to -scaled filenames.
* Always register sideload route with scaled enum
The parent class already registers the sideload route without
'scaled' in its enum, causing a 400 error. Always register
our version so WordPress can fall through to the handler that
accepts the 'scaled' image_size value.
* Override core sideload route to accept scaled size
Core's handler validates first and rejects 'scaled' before
Gutenberg's appended handler is tried. Passing override=true
replaces core's route entirely with ours.
* Add backport changelog for core PR #11015
* Fix PHPCS equals sign alignment in sideload_item
* Fix PHPCS equals sign alignment in sideload_image
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add tests for scaled image sideload metadata
Verify that the sideload endpoint correctly handles the
-scaled image flow: original_image meta is set, attached
file is updated, dimensions/filesize are recorded, and
wp_get_original_image_path resolves to the original.
* improve doc block
* Use ResizeCrop queue step for scaled image
Move the scaled image resize from an inline vipsResizeImage
call to a proper ResizeCrop queue operation. This ensures
the resize respects maxConcurrentImageProcessing limits and
follows the same pattern used for thumbnail generation.
* Add thorough e2e tests for client-side media
Replace weak conditional tests with four unconditional tests
covering filename preservation, scaled image sideloading,
thumbnail base filename correctness, and below-threshold
no-op behavior. Add uploadWithName() helper to enable
filename-aware assertions.
* Remove re-enabling of client-side media from this PR
Move the re-enabling of client-side media processing to a
separate PR so this PR focuses only on the file naming fix.
Restores the disabling shim, bootstrap test override, and
reverts the e2e tests to the trunk version.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Restore improved e2e tests for client-side media file naming
These tests validate the file naming fix, not the re-enabling,
so they belong in this PR.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: ockham <bernhard-reiter@git.wordpress.org>1 parent a1350dd commit dcb6aa4
File tree
8 files changed
+640
-158
lines changed- backport-changelog/7.0
- lib/media
- packages/upload-media/src
- store
- test
- phpunit/media
- test/e2e/specs/editor/various
8 files changed
+640
-158
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 53 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
35 | 39 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| |||
210 | 213 | | |
211 | 214 | | |
212 | 215 | | |
| 216 | + | |
| 217 | + | |
213 | 218 | | |
214 | 219 | | |
215 | 220 | | |
| |||
221 | 226 | | |
222 | 227 | | |
223 | 228 | | |
| 229 | + | |
224 | 230 | | |
225 | 231 | | |
226 | 232 | | |
| |||
275 | 281 | | |
276 | 282 | | |
277 | 283 | | |
278 | | - | |
| 284 | + | |
279 | 285 | | |
280 | 286 | | |
281 | 287 | | |
| |||
381 | 387 | | |
382 | 388 | | |
383 | 389 | | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
384 | 404 | | |
385 | 405 | | |
386 | 406 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
717 | 717 | | |
718 | 718 | | |
719 | 719 | | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
| 720 | + | |
736 | 721 | | |
737 | 722 | | |
738 | 723 | | |
| |||
1126 | 1111 | | |
1127 | 1112 | | |
1128 | 1113 | | |
1129 | | - | |
1130 | | - | |
| 1114 | + | |
| 1115 | + | |
1131 | 1116 | | |
1132 | 1117 | | |
1133 | 1118 | | |
| |||
1205 | 1190 | | |
1206 | 1191 | | |
1207 | 1192 | | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
1208 | 1241 | | |
1209 | 1242 | | |
1210 | 1243 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | | - | |
197 | 196 | | |
198 | 197 | | |
199 | 198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
| |||
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
20 | 38 | | |
21 | 39 | | |
22 | 40 | | |
| |||
0 commit comments