Class: CollectionAdd

wp.media.controller. CollectionAdd


new CollectionAdd( [attributes])

wp.media.controller.CollectionAdd A state for adding attachments to a collection (e.g. video playlist).
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 Title for the state. Displays in the frame's title region.
multiple boolean <optional>
add Whether multi-select is enabled. @todo 'add' doesn't seem do anything special, and gets used as a boolean.
library wp.media.model.Attachments <optional>
The attachments collection to browse. If one is not supplied, a collection of attachments of the specified type will be created.
filterable boolean | string <optional>
uploaded Whether the library is filterable, and if so what filters should be shown. Accepts 'all', 'uploaded', or 'unattached'.
menu string <optional>
gallery Initial mode for the menu region.
content string <optional>
upload Initial mode for the content region. Overridden by persistent user setting if 'contentUserSetting' is true.
router string <optional>
browse Initial mode for the router region.
toolbar string <optional>
gallery-add Initial mode for the toolbar region.
searchable boolean <optional>
true Whether the library is searchable.
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.
contentUserSetting boolean <optional>
true Whether the content region's mode should be set and persisted per user.
priority int <optional>
100 The priority for the state link in the media menu.
syncSelection boolean <optional>
false Whether the Attachments selection should be persisted from the last state. Defaults to false because for this state, because the library of the Edit Gallery state is the selection.
type string The collection's media type. (e.g. 'video').
collectionType string The collection type. (e.g. 'playlist').
Source:

Extends

Methods


<private> [undefined]()

Inherited From:
Overrides:
Source:

<private> _deactivate()

Since:
  • 3.5.0
Inherited From:
Overrides:
Source:

<private> _menu()

Since:
  • 3.5.0
Inherited From:
Overrides:
Source:

<private> _postActivate()

Since:
  • 3.5.0
Inherited From:
Overrides:
Source:

<private> _preActivate()

Since:
  • 3.5.0
Inherited From:
Overrides:
Source:

<private> _ready()

Since:
  • 3.5.0
Inherited From:
Overrides:
Source:

<private> _renderMenu(view)

Create a view in the media menu for the state.
Parameters:
Name Type Description
view media.view.Menu The menu view.
Since:
  • 3.5.0
Inherited From:
Overrides:
Source:

<private> _renderTitle()

Since:
  • 3.5.0
Inherited From:
Overrides:
Source:

<private> _router()

Since:
  • 3.5.0
Inherited From:
Overrides:
Source:

<private> _title()

Since:
  • 3.5.0
Inherited From:
Overrides:
Source:

<private> _updateMenu()

Since:
  • 3.5.0
Inherited From:
Overrides:
Source:

activate()

Since:
  • 3.9.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
Inherited From:
Source:
Returns:
Type
Boolean

constructor()

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

deactivate()

Since:
  • 3.5.0
Inherited From:
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
Inherited From:
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
Inherited From:
Source:
Returns:
Type
Backbone.Model

initialize()

Since:
  • 3.9.0
Overrides:
Source:

isImageAttachment(attachment)

Whether an attachment is image.
Parameters:
Name Type Description
attachment wp.media.model.Attachment
Since:
  • 4.4.1
Inherited From:
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
Inherited From:
Source:

reset()

Reset the library to its initial state.
Since:
  • 3.5.0
Inherited From:
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
Inherited From:
Source:

saveContentMode()

Persist the mode of the content region as a user setting.
Since:
  • 3.5.0
Inherited From:
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
Inherited From:
Source: