File member type types

To create solutions that involve file handling, you are likely to need member types to handle file upload and, in the case of images, file display.

Upload member type type

Use Upload Member Type (library.file.UploadMemberTypeType) to create member types that upload files.

In addition to the typical member type definition members, Upload Member Type has a number of members:

  • File node type specifies the node type to use for the uploaded files. Set this to File With Derivatives for image uploads where you want derivatives such as previews, or leave blank to use the standard File type.
  • Attachment member type specifies the member type to which newly uploaded files should be attached. If it left blank, files are uploaded but not attached to the node.
  • File options controls where the newly uploaded files are placed and, where derivative files are being used, what derivatives should be produced.

The upload member type can be shown in browse or edit mode, or both. If you are attaching files, you can only use upload member types in edit (because you are modifying the node). If you are not attaching files, it generally makes sense to shown the upload member type in browse only, as requiring upload through edit mode would be unnecessarily restrictive.

When used in edit mode, upload member types also allow existing files nodes to be attached.

When used with attachments, upload member types look at the maximum cardinality of the attachment member type, and does not offer the user upload when maximum cardinality is reached.

File options for upload

File options is used to control upload member types.

The format of the options and typical values are given below.

{
"package":".",
"resize":true,
"width":1024,
"height":1024,
"quality":70,
"format":"jpg",
"derivatives": {
"reference": {
"resize":true,
"package":".",
"width":150,
"height":150,
"quality":70,
"format":"jpg"
}
}
}
package

Indicates where the file should be stored relative to the node that uploads the file. Values are:

  • "." – use the node as a package
  • ".." – in the same package as the node
  • reference – used as a dynamic binding reference to find the package
resize Indicates whether the images should be resized.
width, height If the image should be resixed, the size of the box into which they should be resized. Images are only ever made smaller, not larger, and images always retain their aspect ratio.
quality For jpeg images, the compression quality.
format Output format of image, such as png, jpg, etc. Default is the same as the input format.
derivatives An object which contains a list of derivative images to produce. The properties of these objects are used to control the derivation of these images.

Resizing and derivative options only apply when File With Derivatives is being used.

Gallery member type type

Use Gallery Member Type (library.file.GalleryMemberTypeType) to create member types that manages and displays a set of uploaded images.

Image gallery screenshot

In addition to the typical member type definition members, Gallery Member Type has a number of members:

  • Attachment member type specifies the member type which lists the file nodes to be shown on the gallery. It defaults to the gallery member type itself, i.e. the gallery holds and displays links to files.
  • Gallery size specifies the maximum size of the gallery. It is only relevant when Attachment member type is left blank and the gallery member type is showing data held in itself.
  • File options controls the gallery display.

Gallery member types can be shown in browse or edit mode. In browse mode, the gallery shows image previews and offers the user standard node edit actions (edit, copy, move, delete) when they hover over a preview. In edit mode, the gallery shows image previews and offers the user sequencing, edit and remove options when they hover over a preview.

Gallery member types only support edit mode if the Attachment member type is blank, i.e. they can only edit themselves.

Leaving attachment member type blank on upload member type uploads the files to the package. If you want to show the files in the package, you should index the package (e.g. using member type All), and then base the gallery on the index member type.

Gallery member types use Gallery Script to render the gallery. This script can be called from other scripts which need gallery-like functionality.

File options for gallery

File options are used to control the display of the gallery.

The format of the options and typical values are given below.

{
"preview":"reference",
"previewWidth": 150,
"previewHeight": 150,
"previewPadding": 4,
"previewMargin": 15,
"previewBorder": 1
}
preview Reference of the derivative to use for previews. If not present, the main file is used for previews.

previewWidth, previewHeight, previewPadding, previewMargin, previewBorder

Dimensions for preview display in gallery.

If not given, preview width and height default to the width and height of the derivative identified by the preview property. If not specified, these default to system-defined values.