This function converts a relative path (in alphanumeric string form) pointing to a resource (image, etc.) into an alphanumeric string in Data-URI format (click here fore more details).
The syntax of the returned alphanumeric string is:
?data:<media type>;base64,<data>
with:
- media type: MIME type deduced from the URL content analysis,
- data: series of Base64-encoded numbers.
Automatic MIME type deduction starts when the mimeType parameter is not present. It is performed via javax.ImageIO APIs. These natively support the following formats:
- BMP: Bitmap format (image/bmp MIME type),
- WBMP: Wireless Bitmap format (image/vnd.wap.wbmp MIME type),
- PNG: Portable Network Graphics format (image/png MIME type),
- GIF: Graphics interchange format (image/gif MIME type),
- JPEG: Joint Photographic Experts Group format (image/jpeg MIME type).
To specify an unrecognized MIME type, enter the mimeType parameter with an alphanumeric string representing the MIME type. Click here for more details.
Relative path resolution:
The transformation from relative to absolute path is based on the templateOrigin parameter. It can take the following values:
- "main": the resolution is based on the location of the main template (i.e. the one initially chosen by the template engine),
- "caller": the resolution is based on the location of the template calling this macro. This may be different from the main template if it was included using <#include> or <#import> directives.
Parameters
String |
relativePath |
Relative path pointing to an item of data to convert |
Mandatory |
String |
templateOrigin |
Template chosen for relativePath resolution. The possible values are:
|
Optional. The default value is "main". |
String |
mimeType |
Mime type of the data represented by relativePath |
Optional |
Number |
timeout |
Maximum timeout value (in milliseconds) used for connecting to and reading relativePath data. The possible values are: < 0: use of Java default values, = 0: no timeout (unlimited wait), > 0: set value |
Optional. The default value is -1. |
For example
<@hardisFo.foExternalGraphic src=hardisCore.templateResToBase64URI("./resources/logo.png") contentWidth="200px" contentWidth="300px"/>