Thumbnail Function

Files of the types image (image) or resource (generic) are used to store images or any kind of binary data in the CMS. The binary data is stored in the version of the respective file as a blob (binary large object).

The thumbnail function offers you the possibility to create small preview images (thumbnails) from this content data. The HTML user interface of the Content Manager accesses these thumbnails via the thumbnail version field in order to support the user during file selection.

The Content Manager always calls the generateThumbnail Tcl function after data has been assigned to the draft version of an image file or a resource. Its function is to calculate a thumbnail from the binary data passed to it. The Content Manager includes a generateThumbnail function which fulfills this task with the aid of the generateThumbnailForGif, generateThumbnailForJpeg, and generateThumbnailForPng functions built into the Content Manager. The Content Manager stores the thumbnail in the thumbnail version field.

The generateThumbnail function is contained in the generateThumbnail.tcl script. This script is to be found in the serverCmds directory under the config directory of the Content Manager. The callback function can create thumbnails for versions of the jpg, jpeg, gif, and png types (capitalization is irrelevant). It can be extended if necessary to also generate thumbnails for data of other types.

The following arguments are passed to the generateThumbnails function in the order given below.

  • contentId: the ID of the respective version.
  • objId: the ID of the file to which the version with the contentId ID belongs.
  • blobFile: the name of the file containing the source document from which the thumbnail is to be created.
  • contentType: the file name extension of the version.
  • thumbnailSize: the size of the thumbnail in pixels (same value for width and height). It can be configured using the thumbnailSize system configuration entry.

The function returns the base-64-encoded thumbnail image. The Content Manager stores this image as the value of the thumbnail field in the respective version.