[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/ -> media-utils.js (summary)

WordPress dependencies

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

Defines 2 classes

MediaUpload:: (3 methods):
  isPlainObject()
  flattenFormData()
  transformAttachment()

UploadError:: (5 methods):
  validateMimeType()
  getMimeTypesArray()
  validateMimeTypeForUser()
  validateFileSize()
  uploadMedia()


Class: MediaUpload  - X-Ref

isPlainObject(data)   X-Ref
Determines whether the passed argument appears to be a plain object.

param: data The object to inspect.

flattenFormData(formData, key, data)   X-Ref
Recursively flatten data passed to form data, to allow using multi-level objects.

param: {FormData}      formData Form data object.
param: {string}        key      Key to amend to form data object
param: {string|Object} data     Data to be amended to form data.

transformAttachment(attachment)   X-Ref
Transforms an attachment object from the REST API shape into the shape expected by the block editor and other consumers.

param: attachment REST API attachment object.

Class: UploadError  - X-Ref

MediaError class.

Small wrapper around the `Error` class
to hold an error code and a reference to a file object.
validateMimeType(file, allowedTypes)   X-Ref
Verifies if the caller (e.g. a block) supports this mime type.

param: file         File object.
param: allowedTypes List of allowed mime types.

getMimeTypesArray(wpMimeTypesObject)   X-Ref
Browsers may use unexpected mime types, and they differ from browser to browser.
This function computes a flexible array of mime types from the mime type structured provided by the server.
Converts { jpg|jpeg|jpe: "image/jpeg" } into [ "image/jpeg", "image/jpg", "image/jpeg", "image/jpe" ]

return: An array of mime types or null
param: {?Object} wpMimeTypesObject Mime type object received from the server.

validateMimeTypeForUser(file, wpAllowedMimeTypes)   X-Ref
Verifies if the user is allowed to upload this mime type.

param: file               File object.
param: wpAllowedMimeTypes List of allowed mime types and file extensions.

validateFileSize(file, maxUploadFileSize)   X-Ref
Verifies whether the file is within the file upload size limits for the site.

param: file              File object.
param: maxUploadFileSize Maximum upload size in bytes allowed for the site.

uploadMedia({wpAllowedMimeTypes,allowedTypes,additionalData = {},filesList,maxUploadFileSize,onError,onFileChange,signal})   X-Ref
Upload a media file when the file upload button is activated
or when adding a file to the editor via drag & drop.

param: $0                    Parameters object passed to the function.
param: $0.allowedTypes       Array with the types of media that can be uploaded, if unset all types are allowed.
param: $0.additionalData     Additional data to include in the request.
param: $0.filesList          List of files.
param: $0.maxUploadFileSize  Maximum upload size in bytes allowed for the site.
param: $0.onError            Function called when an error happens.
param: $0.onFileChange       Function called each time a file or a temporary representation of the file is available.
param: $0.wpAllowedMimeTypes List of allowed mime types and file extensions.
param: $0.signal             Abort signal.



Generated : Sat Nov 23 08:20:01 2024 Cross-referenced by PHPXref