Namespace: media

wp. media

Create and return a media frame. Handles the default media experience.
Source:

Classes

collection
View

Mixins

mixin
selectionSync

Namespaces

audio
controller
editor
featuredImage
frames
model
string
video
view

Members


<static> ajax

media.ajax( [action], [options] ) Sends an XHR request to WordPress. See wp.ajax.send() in `wp-includes/js/wp-util.js`.
Source:

<static> playlist

Shortcode modeling for playlists.
Since:
  • 4.2.0
Source:

<static> post

media.post( [action], [data] ) Sends a POST request to WordPress. See wp.ajax.post() in `wp-includes/js/wp-util.js`.
Source:

<static> template

media.template( id ) Fetch a JavaScript template for an id, and return a templating function for it. See wp.template() in `wp-includes/js/wp-util.js`.
Source:

Methods


<static> attachment(id)

wp.media.attachment
Parameters:
Name Type Description
id String A string used to identify a model.
Source:
Returns:
Type
wp.media.model.Attachment

<static> coerce(attrs, key)

A helper mixin function to avoid truthy and falsey values being passed as an input that expects booleans. If key is undefined in the map, but has a default value, set it.
Parameters:
Name Type Description
attrs object Map of props from a shortcode or settings.
key string The key within the passed map to check for a value.
Source:
Returns:
The original or coerced value of key within attrs.
Type
mixed | undefined

<static> compare(a, b, ac, bc)

A basic equality comparator for Backbone models. Used to order models within a collection - @see wp.media.model.Attachments.comparator().
Parameters:
Name Type Description
a mixed The primary parameter to compare.
b mixed The primary parameter to compare.
ac string The fallback parameter to compare, a's cid.
bc string The fallback parameter to compare, b's cid.
Source:
Returns:
-1: a should come before b. 0: a and b are of the same rank. 1: b should come before a.
Type
number

<static> fit(dimensions)

Scales a set of dimensions to fit within bounding dimensions.
Parameters:
Name Type Description
dimensions Object
Source:
Returns:
Type
Object

<static> query( [props])

wp.media.query Shorthand for creating a new Attachments Query.
Parameters:
Name Type Argument Description
props object <optional>
Source:
Returns:
Type
wp.media.model.Attachments

<static> truncate(string [, length] [, replacement])

Truncates a string by injecting an ellipsis into the middle. Useful for filenames.
Parameters:
Name Type Argument Default Description
string String
length Number <optional>
30
replacement String <optional>
&hellip;
Source:
Returns:
The string, unless length is greater than string.length.
Type
String