Attachment Picker Application

Last modified by Eleni Cojocariu on 2026/09/30 18:16

Reference

The Attachment Picker Application is what puts the attachmentGalleryPicker macro to work in the wiki's own interface: it ships the wiki page the macro takes its look and its JavaScript from, and the one that adds the "Gallery" tab to the image dialog of the WYSIWYG editor.

The Application is bundled with the XWiki flavor, so a standard instance already has it and there is nothing to install or configure. It requires the module of the macro itself, so installing the Application is what brings the whole picker in; the CKEditor and Solr search interfaces are optional dependencies, since the "Gallery" tab needs the first and the search behind the grid needs the second.

The look and the JavaScript of the picker

The macro renders empty markup and asks, on demand, for the skin extensions of the wiki page Attachment.Picker.Code.AttachmentGalleryPicker, which this Application ships. A LESS XWiki.StyleSheetExtension on that page gives the grid of thumbnails its look, so that page is where to override the picker's style for every Page that uses it.

The same page declares the picker's JavaScript to RequireJS, through two XWiki.UIExtensionClass objects on the org.xwiki.platform.requirejs.module extension point:

ModuleServes
xwiki-attachment-pickerThe picker itself
xwiki-attachment-picker-solr-searchThe search behind the grid

The "Gallery" tab of the image dialog

The wiki page Attachment.Picker.Code.WYSIWYGImageSelector is a UI extension on the org.xwiki.platform.wysiwyg.imageSelector extension point, which is the extension point the "Select Image" dialog of the WYSIWYG editor builds its tabs from. Its content is the picker macro, filtered to images and pointed at the Page being edited:

{{velocity output='false'}}
#set ($discard = $xwiki.jsx.use('Attachment.Picker.Code.WYSIWYGImageSelector'))
{{/velocity}}

{{velocity}}
(% class='attachmentPickerWYSIWYGImageSelector' %)(((
  {{attachmentGalleryPicker filter="image/*" target="$services.rendering.escape($request.documentReference, 'xwiki/2.1')"/}}
)))
{{/velocity}}

A tab of that dialog is described by three parameters of the UI extension, and declaring one of your own takes the same three:

ParameterMeaningValue on the "Gallery" tab
idThe identifier the dialog gives the tab panewysiwygImageSelectorAttachmentPickerTab
titleThe label of the tab, rendered as a translationThe attachment.picker.wysiwyg.imageSelector.title translation
priorityThe place of the tab in the row; the dialog opens on the lowest100, ahead of Tree 200, Upload 300, Icon 400 and Url 500

The first block pulls in the JavaScript the page also carries, which listens to the selection events of the picker and hands the chosen attachment to the image dialog.

FAQ

Why is the picker unstyled and inert when I write its markup by hand?

Nothing but the attachmentGalleryPicker macro asks for the skin extensions of Attachment.Picker.Code.AttachmentGalleryPicker, so markup written by hand gets neither the look of the picker nor its behaviour.

Related

Get Connected