Attachment Picker WebJar

Last modified by Admin on 2026/05/27 13:53

cogJavaScript resources required by the attachment picker module.
Typewebjar
CategoryWebJar
Developed by

XWiki Development Team

Active Installs35
Rating
0 Votes
LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Standard

Compatibility

14.4RC1+

Description

This extension provides the Javascript code for the Attachment Picker Macro.

It also provide events to interact with the attachment picker from some external Javascript code.

Events

  • xwiki:attachmentGalleryPicker:selected: Send when an attachment is selected. The attachment reference of the selected attachment is passed as the first parameter.
  • xwiki:attachmentGalleryPicker:unselected: Send when an attachment is unselected.

Example

Let say the following attachment grid picker is declared.

{{attachmentGalleryPicker id="myid"/}}

It is possible to observe the events send by the macro using the snippet below;

require(['jquery'], function($) {
  // selects the macro by its id.
  const picker = $('#myid')

  // Listen for selected attachment events.
  picker.on('xwiki:attachmentGalleryPicker:selected', function(_target, attachmentReference) {
    // TODO: do something with the attachment reference.
  });

  // Listen for unselected attachment events.
  picker.on('xwiki:attachmentGalleryPicker:unselected', function() {
    // TODO: react to the attachment being unselected.
  });
});

Dependencies

Dependencies for this extension (org.xwiki.platform:xwiki-platform-attachment-picker-webjar 18.4.0):

Get Connected