The component org.ametys.cms.transformation.xslt.ResolveURIComponent allows you to resolve object urls (files, images, pages, content, etc.) from your XSL.

How to use these methods

Add namespace to file headers XSL:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"                                        ...                                        xmlns:resolver="org.ametys.cms.transformation.xslt.ResolveURIComponent"                                        ...                                        
        extension-element-prefixes="... resolver...">                             

So that you can call any of the methods defined below, using ametys:functionName(argument1, argument2, ...)
Example:

<img src="{resolver:resolveBoundedImage(@type, @uri, 350, 200)}" alt="{@altText}"/>                

 

The methods

  1. resolve
  2. resolveImage
  3. resolveBoundedImage
  4. resolveCroppedImage
  5. resolveImageAsBase64(String type, String uri, int height, int width)
  6. resolveBoundedImageAsBase64
  7. resolveCroppedImageAsBase64

resolve

Description:
Returns theurl of a file, page, content, ...
The method can be called with 2, 3 or 4 arguments.

Arguments: 

Name

Type

Mandatory

Description

type

String

yes

File type.
Examples (non-exhaustive list)

  • explorer' for a file from the resource explorer
  • attribute' for a file stored as a content attribute
  • attachment-content' for a content attachment
  • attachment-page' for a page attachment
  • page' for theurl page
  • content' forurl content

uri

String

yes

URI of the file or object.
Depends on type.
For example, for a page, content or resource, the expecteduri is its Ametys identifier.

For a content attribute,uri expects the data path and content identifier (e.g. illustration/image?objectId=content://uuid-uuid-uuid-uuid).

download

Boolean

no

"true" to obtain a url download

absolute

Boolean

no

"true" to obtain an absolute url

resolveImage

Description:
Returns theurl of an image in a given dimension.
The method can be called with 4, 5 or 6 arguments.

Arguments: 

Name

Type

Mandatory

Description

type

String

yes

File type.
Examples (non-exhaustive list)

  • explore' for an image from the resource explorer
  • attribute' for an image stored as a content attribute
  • attachment-content' for a content attachment
  • attachment-page' for a page attachment

uri

String

yes

URI of the image
Depends on the type.
For example, for an image in the Resource Explorer, the expecteduri is its identifier Ametys.

For a content attribute,uri expects the data path and content identifier (e.g. illustration/image?objectId=content://uuid-uuid-uuid-uuid).

height

int

yes

Image height

width

int

yes

Image width

download

Boolean

no

"true" to obtain a url download

absolute

Boolean

no

"true" to obtain an absolute url

resolveBoundedImage

Description:
Returns theurl of an image with an imposed frame (no distortion of the image, no cropping of the image)
The method can be called with 4, 5 or 6 arguments.

Arguments: 

Name

Type

Mandatory

Description

type

String

yes

File type.
Examples (non-exhaustive list)

  • explore' for an image from the resource explorer
  • attribute' for an image stored as a content attribute
  • attachment-content' for a content attachment
  • attachment-page' for a page attachment

uri

String

yes

URI of the image
Depends on the type.
For example, for an image in the Resource Explorer, the expecteduri is its identifier Ametys.

For a content attribute,uri expects the data path and content identifier (e.g. illustration/image?objectId=content://uuid-uuid-uuid-uuid).

maxHeight

int

yes

Maximum image height (frame height)

maxWidth

int

yes

Maximum image width (frame width)

download

Boolean

no

"true" to obtain a url download

absolute

Boolean

no

"true" to obtain an absolute url

 

resolveCroppedImage

Description:
Returns theurl of an image in an imposed dimension with cropping of the image if necessary (no distortion of the image)
The method can be called with 4, 5 or 6 arguments.

Arguments: 

Name

Type

Mandatory

Description

type

String

yes

File type.
Examples (non-exhaustive list)

  • explore' for an image from the resource explorer
  • attribute' for an image stored as a content attribute
  • attachment-content' for a content attachment
  • attachment-page' for a page attachment

uri

String

yes

URI of the image
Depends on the type.
For example, for an image in the Resource Explorer, the expecteduri is its identifier Ametys.

For a content attribute,uri expects the data path and content identifier (e.g. illustration/image?objectId=content://uuid-uuid-uuid-uuid).

croppedHeight

int

yes

Image height

croppedWidth

int

yes

Image width

download

Boolean

no

"true" to obtain a url download

absolute

Boolean

no

"true" to obtain an absolute url

resolveImageAsBase64(String type, String uri, int height, int width)

Description:
Returns theurl of a base64 image in an imposed dimension (image distortion possible)
The method has 4 arguments

Arguments: 

Name

Type

Mandatory

Description

type

String

yes

File type.
Examples (non-exhaustive list)

  • explore' for an image from the resource explorer
  • attribute' for an image stored as a content attribute
  • attachment-content' for a content attachment
  • attachment-page' for a page attachment

uri

String

yes

URI of the image
Depends on the type.
For example, for an image in the Resource Explorer, the expecteduri is its identifier Ametys.

For a content attribute,uri expects the data path and content identifier (e.g. illustration/image?objectId=content://uuid-uuid-uuid-uuid).

height

int

yes

Image height

width

int

yes

Image width

 

resolveBoundedImageAsBase64

Description:
Returns theurl of a base64 image in an imposed frame (no image distortion, no cropping)
The method has 4 arguments

Arguments: 

Name

Type

Mandatory

Description

type

String

yes

File type.
Examples (non-exhaustive list)

  • explore' for an image from the resource explorer
  • attribute' for an image stored as a content attribute
  • attachment-content' for a content attachment
  • attachment-page' for a page attachment

 

 

uri

String

yes

URI of the image
Depends on the type.
For example, for an image in the Resource Explorer, the expecteduri is its identifier Ametys.

For a content attribute,uri expects the data path and content identifier (e.g. illustration/image?objectId=content://uuid-uuid-uuid-uuid).

maxHeight

int

yes

Maximum image height

maxWidth

int

yes

Maximum image width

 

resolveCroppedImageAsBase64

Description:
Returns theurl of a base64 image in an imposed dimension with cropping of the image if necessary (no distortion of the image)
The method has 4 arguments

Arguments: 

Name

Type

Mandatory

Description

type

String

yes

File type.
Examples (non-exhaustive list)

  • explore' for an image from the resource explorer
  • attribute' for an image stored as a content attribute
  • attachment-content' for a content attachment
  • attachment-page' for a page attachment

 

 

uri

String

yes

URI of the image
Depends on the type.
For example, for an image in the Resource Explorer, the expecteduri is its identifier Ametys.

For a content attribute,uri expects the data path and content identifier (e.g. illustration/image?objectId=content://uuid-uuid-uuid-uuid).

croppedHeight

int

yes

Image height

croppedWidth

int

yes

Image width

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Back to top