Contribute to Docs Contribute to Docs

Media Picker

Methods

Open

piranha.mediapicker.open(callback, filter = null, folderId = null);

Parameters

Callback

The callback function is called when a media item is selected in the media picker. The provided function should accept one parameter which will be the selected media object. Let's take a look how it could look if we selected an image from the media library.

{
    contentType: "image/png",
    filename: "banner.png",
    folderId: "96cf512e-9f10-4488-95cc-e92204769fb5",    ‚Äč
    height: 861,
    id: "ac34a625-b140-445b-b948-3221a0b02292",
    lastModified: "2019-10-17",
    publicUrl: "https://...",
    size: "674,73 KB",
    type: "Image",
    width: 1310
}

The method can easily be called with either an inline callback or by providing a previously defined function:

piranha.mediapicker.open(function (m) {
    console.log(m);
});
Filter

The filter is an optional String parameter used to filter the media assets available to choose from in the media picker. Valid values are:

Audio, Document, Image, Video

FolderId