Create and return a media frame.
Handles the default media experience.
- Source:
Classes
Mixins
Namespaces
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 idString A string used to identify a model. - Source:
Returns:
-
<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 attrsobject Map of props from a shortcode or settings. keystring 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 amixed The primary parameter to compare. bmixed The primary parameter to compare. acstring The fallback parameter to compare, a's cid. bcstring 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 dimensionsObject - Source:
Returns:
- Type
- Object
-
<static> query( [props])
-
wp.media.query Shorthand for creating a new Attachments Query.
Parameters:
Name Type Argument Description propsobject <optional>
- Source:
Returns:
-
<static> truncate(string [, length] [, replacement])
-
Truncates a string by injecting an ellipsis into the middle. Useful for filenames.
Parameters:
Name Type Argument Default Description stringString lengthNumber <optional>
30 replacementString <optional>
… - Source:
Returns:
The string, unless length is greater than string.length.- Type
- String