Attachment Selector Macro

The Attachment Selector is a bundled picker associated with XWiki object properties of type String. The macro is used by default when choosing the user avatar and it offers a dedicated UI for selecting from the available attached files. After selecting an attachment, the property value becomes the name of that attachment.

The selector displays an attachment gallery which lists the attached files of the current document provided their format is an accepted one. Users can also upload new attachments, select or delete the existing attachments.

Usage

{{attachmentSelector classname="<classname>" property="<property>" cssClass="<cssClass>" savemode="<form|direct>"
buttontext="<buttontext>" defaultValue="<defaultValue>" displayImage="<true|false>" width="<width>" height="<height>"
alternateText="<alternateText>" link="<true|false>" targetdocname="<targetdocname>" versionSummary="<true|false>" /}}

Parameters

NameOptionalDescriptionAccepted Values
classnameNoThe full name of the document containing the XWiki class with the property associated with the picker.-
propertyNoThe name of the class property associated with the picker.-
objectYesThe identifier (i.e. a number) of the object for which the property is displayed by this picker.If missing, the first instance of the class (0) given by the parameter classname found in the document will be considered.
cssClassYesA CSS class for the element surrounding the displayed property value.-
savemodeYesDefines the way the property is updated
  • form (the default value) meaning that the selected value is stored in an input that will be saved via an external form.
  • direct meaning that the update of the property value is done by the picker.
buttontextYesThe text of the button that triggers the pickerThe default value is $services.localization.render('xe.attachmentSelector.selectFile').
defaultValueYesThe name of the attachment displayed in view mode when the property is empty.This parameter should be either empty or a reference to a wiki attachment.
filterYesA comma separated list of file extensions accepted by the property.If empty, all file formats are accepted.
displayImageYesA flag stating whether images are displayed or whether only their name is printed.
  • true
  • false (the default value)
widthYesThe width of the displayed image which is only taken into account if displayImage is set to "true".-
heightYesThe height of the displayed image, only taken into account if displayImage is set to "true".-
alternateTextYesThe alternate text (corresponding to the alt attribute) of the displayed image, only taken into account if displayImage is set to "true".-
linkYesA flag stating whether a link to the attachment is associated with the name/image of the attachment in view mode.
  • true
  • false (the default value)
targetdocnameYesAn optional reference to a document to use as the source and target for the attachments to display.The name of the current document is used by default.
versionSummaryYesWhether to allow the user to enter a version summary that will be recorded in the history. An automatic message is used when no version summary is provided or in case the version summary input is not displayed.
  • true
  • false (the default value)
Starting with version 9.5, when uploading a new file from the Attachment Selector you have the option to replace the selected attachment.

ChangePhoto.png

Examples

Example 1

{{attachmentSelector classname="XWiki.XWikiUsers" property="avatar" savemode="direct" displayImage="true"
width="120" link="true" filter="png,jpg,gif" defaultValue="XWiki.XWikiUserSheet@noavatar.png"/}}

will display

The XWiki class is "XWiki.XWikiUsers" and the allowed formats are "PNG", "JPG" and "GIF". The class property associated with the picker is "avatar" and the update of the property value is done by the picker. Also, the image width is "120 px" and in case no attached image is found, the "noavatar.png" image attached to "XWiki.XWikiUserSheet" will be displayed. 

AttachmentSelectorImages.png

Example 2

{{attachmentSelector classname="XWiki.EmployeesClass" property="curriculumvitae" savemode="direct"
displayImage="true"  width="120" filter="odt,pdf,doc,odp" /}}

will display

AttachmentSelectorFiles.png

  

Related Pages

Search this space

 

Most popular tags

Failed to execute the [groovy] macro
  1. access rights
  2. activity stream
  3. annotation
  4. attachment
  5. comment
  6. Document Tree Macro
  7. export
  8. Extension Manager
  9. Flamingo skin
  10. global user
  11. Groovy event listener
  12. group
  13. nested page
  14. search
  15. skin
  16. syntax
  17. user
  18. user profile
  19. velocity macros
  20. wiki
  21. wysiwyg
  22. XWiki Applications
  23. xwikiattachment_archive table
  24. xwikiattachment table
  25. xwikiattrecyclebin table
  26. xwikiproperties table

[Display all tags from this space]