[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-admin/js/ -> media-frame-upload.js (summary)

Routes media frame uploads through the client-side media pipeline. Every wp.media frame - the Media Library grid on wp-admin/upload.php and the media modal the block editor, the site editor and the block widgets screen open - uploads via wp.Uploader / plupload to async-upload.php. When the browser is cross-origin isolated and supports the client-side pipeline, this script intercepts the uploader's FilesAdded handler and hands files to wp.mediaUploadPipeline (media-upload-pipeline.js) instead: the original image is uploaded via the REST API and thumbnails are generated in the browser (wasm-vips), then sideloaded and finalized.

File Size: 271 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 5 functions

  maybeResetQueue()
  handleSuccess()
  handleError()
  isAttachmentUploader()
  handleFilesAdded()

Functions
Functions that are not part of a class:

maybeResetQueue()   X-Ref
Resets the upload queue once every attachment has finished uploading.

Parity with wp-plupload.js so browse mode flips back when done.

handleSuccess( wpUploader, model, attachment )   X-Ref
Handles a completed upload by syncing the grid tile with the server data.

param: {WPUploader}         wpUploader The wp.Uploader instance that queued the file.
param: {WPAttachment}       model      The placeholder Attachment model.
param: {PipelineAttachment} attachment The finalized attachment from the pipeline.

handleError( wpUploader, model, error, fileName )   X-Ref
Handles an upload error by removing the tile and surfacing the message.

The error goes into wp.Uploader.errors exactly like a classic upload
error, so the grid's error sidebar renders it, announces it, and
moves focus to its Dismiss button.

param: {WPUploader}   wpUploader The wp.Uploader instance that queued the file.
param: {WPAttachment} model      The placeholder Attachment model.
param: {UploadError}  error      The upload error.
param: {string}       fileName   Name of the file (for the error label).

isAttachmentUploader( up )   X-Ref
Whether a plupload uploader posts attachments the way wp.Uploader does
by default.

The init wrapper below reaches every wp.Uploader built on the page,
and a plugin can build one for its own purposes. Core's defaults tell
an attachment upload apart: it posts to async-upload.php with the
`upload-attachment` action. Anything a plugin pointed elsewhere, or
gave another action, is uploading something else and is left alone.

param: {plupload.Uploader} up The plupload uploader instance.
return: {boolean} True when the uploader posts attachments.

handleFilesAdded( wpUploader, up, files )   X-Ref
Intercepts files added to a plupload uploader.

Builds the same placeholder tiles as wp-plupload for the files the
pipeline takes (see wp.mediaUploadPipeline.routeBatch()). Returns
undefined to leave the whole batch to plupload's built-in handler.

param: {WPUploader}        wpUploader The wp.Uploader instance.
param: {plupload.Uploader} up         The plupload uploader instance.
param: {plupload.File[]}   files      Files added to the queue.
return: {boolean|undefined} False to suppress the built-in handler.



Generated : Tue Oct 20 08:20:34 2026 Cross-referenced by PHPXref