Skip to content

feat: process New Block Editor media uploads with app Media settings#25824

Open
dcalhoun wants to merge 8 commits into
trunkfrom
feat/process-gutenberg-kit-media-uploads
Open

feat: process New Block Editor media uploads with app Media settings#25824
dcalhoun wants to merge 8 commits into
trunkfrom
feat/process-gutenberg-kit-media-uploads

Conversation

@dcalhoun

@dcalhoun dcalhoun commented Jul 22, 2026

Copy link
Copy Markdown
Member

Description

Ref CMM-1249. Ref CMM-2155.

Integrates GutenbergKit's native media upload pipeline (wordpress-mobile/GutenbergKit#357) so device media picked in the New Block Editor (NBE) is processed natively before upload, honoring the app's Media settings: Optimize Images, Max Image Upload Size, Image Quality, Max Video Upload Size, and Remove Location From Media. Previously these uploads went directly from the WebView to the REST API with no processing, bypassing the settings the legacy editor and My Site > Media already honor.

How it works

  • GBKMediaUploadProcessor implements GutenbergKit's new MediaUploadDelegate. When the editor uploads a device file, GutenbergKit's localhost upload server hands the staged file to processFile, which reuses MediaURLExporter with the same option mapping as MediaImportService:
    • Images are resized/recompressed per the Optimize Images settings, GPS EXIF is stripped per Remove Location, and non-web-safe formats (e.g. HEIC) are converted to JPEG, mirroring ItemProviderMediaExporter.
    • Videos are transcoded per the Max Video Upload Size preset, with the free-plan duration limit enforced (videoLimitExceeded surfaces WordPress's "requires a paid plan" message in the editor).
    • GIFs and non-media files pass through untouched (GutenbergKit forwards the original bytes verbatim); disallowed file extensions are rejected with the standard localized error.
    • When processing would be a no-op (optimization and location stripping disabled, web-safe format), the original file passes through without re-encoding.
  • Upload itself still uses GutenbergKit's default uploader, which relays the raw WordPress REST response to the editor, so attachment objects, sub-sizes, and error notices behave identically to a direct upload.
  • Wired unconditionally in PostGBKEditorViewController (covers posts, pages, and custom post types). If GutenbergKit's upload server cannot start, it degrades gracefully to the standard WebView upload path.

Notes

  • Modules/Package.swift temporarily points at the pr-build/357 GutenbergKit snapshot; it must be swapped to a tagged release once feat: proxy media uploads through native delegate for processing GutenbergKit#357 ships.
  • Uploaded attachments are not inserted into the local Core Data Media store, so My Site > Media shows them after the next sync. This matches the NBE's pre-existing behavior; syncing after upload is a possible follow-up.

Testing instructions

  1. Build and run the Jetpack scheme and sign in.
  2. Image resize: In App Settings > Media, enable Optimize Images with Max Image Upload Size 2000. Open a post in the NBE, add an Image block, and upload a photo larger than 2000px from the device. Verify the upload succeeds and the stored full-size image is at most 2000px (inspect the attachment in wp-admin or the block's URL).
  3. No-op passthrough: Disable Optimize Images and Remove Location From Media, upload the same photo, and verify it retains its original dimensions.
  4. Location stripping: Enable Remove Location From Media, upload a GPS-tagged photo, download the original from the site, and verify it has no GPS EXIF data.
  5. HEIC: Upload a HEIC image via the Files app and verify it arrives as JPEG.
  6. GIF: Upload an animated GIF and verify it still animates on the published post.
  7. Video: Set Max Video Upload Size to 480p, upload a video, and verify the transcoded resolution. On a free WordPress.com site, upload a video longer than 5 minutes and verify the "requires a paid plan" notice appears.
  8. Verify behavior on both a WordPress.com site and a self-hosted site with an application password.

@dcalhoun dcalhoun added Media Gutenberg Editing and display of Gutenberg blocks. [Type] Enhancement labels Jul 22, 2026
@dcalhoun dcalhoun added this to the 27.2 milestone Jul 22, 2026
dcalhoun added 5 commits July 22, 2026 16:02
Gates the upcoming native media upload processing for the experimental
block editor, with a Debug-menu override for quick disabling.
Points GutenbergKit at the XCFramework snapshot for
wordpress-mobile/GutenbergKit#357, which adds the native media upload
server and MediaUploadDelegate. Swap to a tagged release before merge.
Implements GutenbergKit's MediaUploadDelegate so device media picked in
the experimental block editor is processed natively before upload,
honoring the app's Media settings: Optimize Images, Max Image Upload
Size, Image Quality, Max Video Upload Size, and Remove Location From
Media. Previously these uploads went directly from the WebView to the
REST API with no processing.

GBKMediaUploadProcessor mirrors the exporter option mapping used by
MediaImportService and reuses MediaURLExporter, so the editor now
matches the behavior of the legacy editor and My Site > Media. GIFs
and non-media files pass through untouched, and non-web-safe image
formats (e.g. HEIC) are converted to JPEG. Uploads still use
GutenbergKit's default uploader, which relays the raw WordPress
response to the editor.
Verifies resizing, GPS stripping, HEIC-to-JPEG conversion, GIF and
no-op passthrough, disallowed file extensions, and the video duration
limit using the existing media fixtures.
Adds the gbkMediaUploadOptimization flag to the Experimental Features
list and aligns display names with the "New Block Editor (NBE)"
naming.
@dcalhoun
dcalhoun force-pushed the feat/process-gutenberg-kit-media-uploads branch from 5eb00ce to f373395 Compare July 22, 2026 20:12
Comment thread WordPress/Classes/Utility/BuildInformation/RemoteFeatureFlag.swift Outdated
@dcalhoun
dcalhoun marked this pull request as ready for review July 22, 2026 20:37
@dcalhoun
dcalhoun requested a review from jkmassel July 22, 2026 20:37
@wpmobilebot

wpmobilebot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number33395
VersionPR #25824
Bundle IDorg.wordpress.alpha
Commitc908b31
Installation URL2jcng7cmc82d0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number33395
VersionPR #25824
Bundle IDcom.jetpack.alpha
Commitc908b31
Installation URL1rrrehhc9o3q0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

dcalhoun added 3 commits July 23, 2026 09:47
Removes the gbkMediaUploadOptimization gate ahead of reverting the
flag. GutenbergKit degrades gracefully if the upload server cannot
start, so a dedicated kill switch isn't needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gutenberg Editing and display of Gutenberg blocks. Media [Type] Enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants