Class LoadImageDirective

java.lang.Object
ch.tocco.nice2.dms.impl.freemarker.LoadImageDirective
All Implemented Interfaces:
Nice2TemplateDirective, TemplateIdentifiers, freemarker.template.TemplateDirectiveModel, freemarker.template.TemplateModel

public class LoadImageDirective extends Object implements Nice2TemplateDirective, TemplateIdentifiers
Loads an image of an entity as base64 data URI (usable as src of an img tag). An empty string is returned if there is no image or the user is not allowed to read it.

Parameters:

  • path (required): The path from the entity to the image. The path ends in a document (binary) field and may follow relations (e.g. relSerial_correspondence.signature_image1). Only to-one relations can be followed, to-many relations need a selector. The user needs the content read permission of the document, e.g. offline documents are only visible with write permission.
  • entity (optional): The entity the path starts at. If not set, the base data of the template is used.
  • name (optional): The name of the variable to load the image to. If no name is passed, the image is printed.
  • Constructor Details

    • LoadImageDirective

      public LoadImageDirective(org.slf4j.Logger log, EntityDocumentsService entityDocumentsService)
  • Method Details

    • execute

      public void execute(freemarker.core.Environment env, Map params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body) throws freemarker.template.TemplateException, IOException
      Specified by:
      execute in interface freemarker.template.TemplateDirectiveModel
      Throws:
      freemarker.template.TemplateException
      IOException