Class: Library

wp.media.controller. Library


new Library()

wp.media.controller.MediaLibrary
Source:

Extends

Methods


activate()

Since:
  • 3.5.0
Overrides:
Source:

canEmbed(attachment)

Whether an attachment can be embedded (audio or video).
Parameters:
Name Type Description
attachment wp.media.model.Attachment
Since:
  • 3.6.0
Overrides:
Source:
Returns:
Type
Boolean

constructor()

Constructor.
Since:
  • 3.5.0
Inherited From:
Overrides:
Source:

deactivate()

Since:
  • 3.5.0
Overrides:
Source:

defaultDisplaySettings(attachment)

Given an attachment, create attachment display settings properties.
Parameters:
Name Type Description
attachment wp.media.model.Attachment
Since:
  • 3.6.0
Overrides:
Source:
Returns:
Type
Object

display(attachment)

Create a model to represent display settings (alignment, etc.) for an attachment.
Parameters:
Name Type Description
attachment wp.media.model.Attachment
Since:
  • 3.5.0
Overrides:
Source:
Returns:
Type
Backbone.Model

initialize()

If a library isn't provided, query all media items. If a selection instance isn't provided, create one.
Since:
  • 3.5.0
Overrides:
Source:

isImageAttachment(attachment)

Whether an attachment is image.
Parameters:
Name Type Description
attachment wp.media.model.Attachment
Since:
  • 4.4.1
Overrides:
Source:
Returns:
Type
Boolean

<abstract> ready()

Ready event callback.
Since:
  • 3.5.0
Inherited From:
Overrides:
Source:

refreshContent()

If the state is active, no items are selected, and the current content mode is not an option in the state's router (provided the state has a router), reset the content mode to the default.
Since:
  • 3.5.0
Overrides:
Source:

reset()

Reset the library to its initial state.
Since:
  • 3.5.0
Overrides:
Source:

resetDisplays()

Reset the attachment display settings defaults to the site options. If site options don't define them, fall back to a persistent user setting.
Since:
  • 3.5.0
Overrides:
Source:

saveContentMode()

Persist the mode of the content region as a user setting.
Since:
  • 3.5.0
Overrides:
Source:

uploading(attachment)

Callback handler when an attachment is uploaded. Switch to the Media Library if uploaded from the 'Upload Files' tab. Adds any uploading attachments to the selection. If the state only supports one attachment to be selected and multiple attachments are uploaded, the last attachment in the upload queue will be selected.
Parameters:
Name Type Description
attachment wp.media.model.Attachment
Since:
  • 3.5.0
Overrides:
Source:

Class: Library

wp.media.controller. Library


new Library( [attributes])

wp.media.controller.Library A state for choosing an attachment or group of attachments from the media library.
Parameters:
Name Type Argument Description
attributes object <optional>
The attributes hash passed to the state.
Properties
Name Type Argument Default Description
id string <optional>
library Unique identifier.
title string <optional>
Media library Title for the state. Displays in the media menu and the frame's title region.
library wp.media.model.Attachments <optional>
The attachments collection to browse. If one is not supplied, a collection of all attachments will be created.
selection wp.media.model.Selection | object <optional>
A collection to contain attachment selections within the state. If the 'selection' attribute is a plain JS object, a Selection will be created using its values as the selection instance's `props` model. Otherwise, it will copy the library's `props` model.
multiple boolean <optional>
false Whether multi-select is enabled.
content string <optional>
upload Initial mode for the content region. Overridden by persistent user setting if 'contentUserSetting' is true.
menu string <optional>
default Initial mode for the menu region.
router string <optional>
browse Initial mode for the router region.
toolbar string <optional>
select Initial mode for the toolbar region.
searchable boolean <optional>
true Whether the library is searchable.
filterable boolean | string <optional>
false Whether the library is filterable, and if so what filters should be shown. Accepts 'all', 'uploaded', or 'unattached'.
sortable boolean <optional>
true Whether the Attachments should be sortable. Depends on the orderby property being set to menuOrder on the attachments collection.
autoSelect boolean <optional>
true Whether an uploaded attachment should be automatically added to the selection.
describe boolean <optional>
false Whether to offer UI to describe attachments - e.g. captioning images in a gallery.
contentUserSetting boolean <optional>
true Whether the content region's mode should be set and persisted per user.
syncSelection boolean <optional>
true Whether the Attachments selection should be persisted from the last state.
Mixes In:
  • media.selectionSync
Source:

Extends

Methods


activate()

Since:
  • 3.5.0
Overrides:
Source:

canEmbed(attachment)

Whether an attachment can be embedded (audio or video).
Parameters:
Name Type Description
attachment wp.media.model.Attachment
Since:
  • 3.6.0
Overrides:
Source:
Returns:
Type
Boolean

constructor()

Constructor.
Since:
  • 3.5.0
Inherited From:
Overrides:
Source:

deactivate()

Since:
  • 3.5.0
Overrides:
Source:

defaultDisplaySettings(attachment)

Given an attachment, create attachment display settings properties.
Parameters:
Name Type Description
attachment wp.media.model.Attachment
Since:
  • 3.6.0
Overrides:
Source:
Returns:
Type
Object

display(attachment)

Create a model to represent display settings (alignment, etc.) for an attachment.
Parameters:
Name Type Description
attachment wp.media.model.Attachment
Since:
  • 3.5.0
Overrides:
Source:
Returns:
Type
Backbone.Model

initialize()

If a library isn't provided, query all media items. If a selection instance isn't provided, create one.
Since:
  • 3.5.0
Overrides:
Source:

isImageAttachment(attachment)

Whether an attachment is image.
Parameters:
Name Type Description
attachment wp.media.model.Attachment
Since:
  • 4.4.1
Overrides:
Source:
Returns:
Type
Boolean

<abstract> ready()

Ready event callback.
Since:
  • 3.5.0
Inherited From:
Overrides:
Source:

refreshContent()

If the state is active, no items are selected, and the current content mode is not an option in the state's router (provided the state has a router), reset the content mode to the default.
Since:
  • 3.5.0
Overrides:
Source:

reset()

Reset the library to its initial state.
Since:
  • 3.5.0
Overrides:
Source:

resetDisplays()

Reset the attachment display settings defaults to the site options. If site options don't define them, fall back to a persistent user setting.
Since:
  • 3.5.0
Overrides:
Source:

saveContentMode()

Persist the mode of the content region as a user setting.
Since:
  • 3.5.0
Overrides:
Source:

uploading(attachment)

Callback handler when an attachment is uploaded. Switch to the Media Library if uploaded from the 'Upload Files' tab. Adds any uploading attachments to the selection. If the state only supports one attachment to be selected and multiple attachments are uploaded, the last attachment in the upload queue will be selected.
Parameters:
Name Type Description
attachment wp.media.model.Attachment
Since:
  • 3.5.0
Overrides:
Source: