/** * This file is auto generated from JavaDoc. Do not modify it manually. */ import type { ImageScaler } from "../../types/senselogic/sitevision/api/render/ImageScaler"; import type { Node } from "../../types/javax/jcr/Node"; import type { String } from "../../types/java/lang/String"; import type SourceSetMode from "../SourceSetMode"; import type DimensionMode from "../DimensionMode"; import type FetchPriorityMode from "../FetchPriorityMode"; /** * ImageRenderer is a stateful utility interface that can be used to render valid html img elements based on images of the website. * *
* ImageRenderer is very suitable when rendering more than one image or when you want to render images in different sizes than the original * images (e.g. "thumbnails"). ImageRenderer also supports "hover" images, i.e. another image is displayed whenever the cursor hovers over the image. *
* ** ImageRenderer has few attributes: *
*null.
* null.
* null. (though, the element class is always
* 'sv-noborder', which is equivalent with style 'border:none')
* null.
* true
* and there are no description set, the renderer will try to get the description metadata for the image. Default is false.
* description will be used as value.
* Default is false.
* true and there are no description available, the renderer will try to get the description metadata for the image.
* Default is false.
* true.
* srcset attribute rendering strategy. Default is {@link SourceSetMode#AUTO}.
* null.
* true.
* true.
* width/height css style properties rendering strategy. Default is {@link DimensionMode#AUTO}.
* fetchpriority attribute rendering strategy. Default is {@link FetchPriorityMode#OFF}.
* null (no custom classes).
* null (no custom data attributes).
* null (no custom aria attributes).
* * Using the ImageRenderer is pretty straightforward, if you remember that it is stateful and that the previously loaded image * will be cleared whenever you try to load a new one. Conceptually you would typically use it like this: *
** When you have rendered once, you can re-use the ImageRenderer until you are done. Something like: *
*
* Example of how this strategy could be implemented in Velocity:
* (You want to do a simple listing of some image nodes in a collection/iterator "$images", and for each image a thumbnail should be displayed
* on top of the original
*
* ## Get an ImageScaler that scales images to size 200x100
* #set ($imageScaler = $sitevisionUtils.getImageScaler(200, 100))
*
* ## Get an ImageRenderer and apply the ImageScaler
* #set ($imageRenderer = $sitevisionUtils.imageRenderer)
* $imageRenderer.setImageScaler($imageScaler)
* $imageRenderer.clearSourceSetMode() ## Disable source set (to ensure it won't interfere with the scaled size)
*
* ## Iterate through images and render them
* <ul style="list-style:none">
* #foreach ($image in $images)
* ## Load an image
* $imageRenderer.update($image)
*
* <li>
* ## Render the thumbnail (ensure scaler is active)
* $imageRenderer.forceUseImageScaler()
* $imageRenderer.render()
*
* ## Render image (ensure scaler is inactive)
* $imageRenderer.clearUseImageScaler()
* $imageRenderer.render()
* </li>
* #end
* </ul>
*
*
*
* Since ImageRenderer is stateful and likely will be used in Velocity frequently, there are some "shortcuts" that might be useful.
* Due to the lack of proper boolean support in Velocity, the boolean attributes has corresponding force/clear methods to set the boolean
* to true/false. Due to the lack of proper null support in Velocity, some attributes has clear methods to set the attribute to null.
* For example:
*
forceUseImageScaler() results in an execution of setUseImageScaler(true)clearUseImageScaler() results in an execution of setUseImageScaler(false)forceUseTitleRendering() results in an execution of setUseTitleRendering(true)clearUseTitleRendering() results in an execution of setUseTitleRendering(false)forceSourceSetMode() results in an execution of setSourceSetMode(SourceSetMode.ON)clearSourceSetMode() results in an execution of setSourceSetMode(SourceSetMode.OFF)clearHoverImage() results in an execution of setHoverImage(null)clearStyle() results in an execution of setStyle(null)forceUseLazyLoad() results in an execution of setLazyLoad(true)clearUseLazyLoad() results in an execution of setLazyLoad(false)
*
* Image type support! This interface accepts all types of images as specified by
* {@link senselogic.sitevision.api.webresource.mime.MimeTypeUtil#isImageType(String)}.
* This means that all such images can loaded and rendered, but note that not all types can be scaled by an ImageScaler.
*
*
* Thread Note! The render method is NOT thread safe! If two threads simultaneously executes
* the render method on the SAME ImageRenderer instance, the rendered result is undeterminable. This is in almost
* all cases nothing you need to worry about, unless your portlet or servlet actually creates a separate Thread
* and starts it. If so - ensure all your created threads creates and uses their own ImageRenderer instance!
*
* Note/Tip! This interface helps rendering images. If you want to render linked images, you would typically * use the {@link senselogic.sitevision.api.render.ImageLinkRenderer} instead. *
* *
* An instance of the Sitevision class implementing this interface can be obtained via {@link senselogic.sitevision.api.Utils#getImageRenderer()}.
* See {@link senselogic.sitevision.api.Utils} for how to obtain an instance of the Utils interface.
*
useImageScaler is true.
* * An image scaler is obtained via {@link senselogic.sitevision.api.Utils#getImageScaler(int, int)} *
* @param anImageScaler the image scaler that can be used by the renderer to create scaled images */ setImageScaler(anImageScaler: ImageScaler): void; /** * Removes the image scaler, i.e. executessetImageScaler(null)
* @see #setImageScaler(ImageScaler)
*/
clearImageScaler(): void;
/**
* Whether or not an image scaler is loaded.
* @return true if an image scaler is loaded, false if not.
*/
isImageScalerLoaded(): boolean;
/**
* Decides if an image scaler should be used or not.
*
* Default is true.
*
true, an image scaler will be used if it is set. If false, no image scaler will be used even if it is set.
*/
setUseImageScaler(useImageScaler: boolean): void;
/**
* Utility method for executing setUseImageScaler(true)
* @see #setUseImageScaler(boolean)
*/
forceUseImageScaler(): void;
/**
* Utility method for executing setUseImageScaler(false)
* @see #setUseImageScaler(boolean)
*/
clearUseImageScaler(): void;
/**
* Sets a hover image that will be activated on the onmouseover JavaScript event.
* * If the rendered image width exceeds 160 pixels, source sets must be disabled via * {@link #setSourceSetMode(SourceSetMode)} with {@link SourceSetMode#OFF} * for the hover image to work. *
* @param anImageNode the hover image (a node with primary node type sv:image) */ setHoverImage(anImageNode: Node): void; /** * Utility method for executingsetHoverImage(null)
* @see #setHoverImage(javax.jcr.Node)
*/
clearHoverImage(): void;
/**
* Whether or not a hover image is loaded.
* @return true if a hover image node is loaded, false if not.
*/
isHoverImageLoaded(): boolean;
/**
* Sets the image to be rendered.
*
* If anImageNode is not a proper image, the image will be considered as null, i.e.
* the renderer will not have any image in subsequent render execution.
*
* If anImageNode is not a proper image, the image will be considered as null, i.e.
* the renderer will not have any image in subsequent render execution.
*
* If anImageNode is not a proper image, the image will be considered as null, i.e.
* the renderer will not have any image in subsequent render execution.
*
null to clear any previous description
*/
update(anImageNode: Node, aDescription: String | string): void;
/**
* Whether or not an image is loaded.
* @return true if an image node is loaded, false if not.
*/
isImageLoaded(): boolean;
/**
* A description fallback strategy that makes it possible to render a description value even if no description has been set.
* When autoDescription is enabled, the renderer will try to use the image description metadata if no description is set.
*
* Default is false.
*
setUseAutoDescription(true)
* @see #setUseAutoDescription(boolean)
*/
forceUseAutoDescription(): void;
/**
* Utility method for executing setUseAutoDescription(false)
* @see #setUseAutoDescription(boolean)
*/
clearUseAutoDescription(): void;
/**
* The srcset attribute rendering strategy.
* * Default is {@link SourceSetMode#AUTO}. *
* @param aSourceSetMode the source set mode, determines whether or not asrcset attribute should be rendered
* @since Sitevision 4.1
*/
setSourceSetMode(aSourceSetMode: SourceSetMode): void;
/**
* Utility method for executing setSourceSetMode({@link SourceSetMode#ON}).
* @see #setSourceSetMode(SourceSetMode)
* @since Sitevision 4.1
*/
forceSourceSetMode(): void;
/**
* Utility method for executing setSourceSetMode({@link SourceSetMode#OFF}).
* @see #setSourceSetMode(SourceSetMode)
* @since Sitevision 4.1
*/
clearSourceSetMode(): void;
/**
* Utility method for executing setSourceSetMode({@link SourceSetMode#AUTO}).
* @see #setSourceSetMode(SourceSetMode)
* @since Sitevision 4.1
*/
resetSourceSetMode(): void;
/**
* The width/height rendering strategy.
* * Default is {@link DimensionMode#AUTO}. *
* @param aDimensionMode the dimension mode, determines how to render width/height css style properties * @since Sitevision 5 */ setDimensionMode(aDimensionMode: DimensionMode): void; /** * Utility method for executingsetDimensionMode({@link DimensionMode#ON}).
* @since Sitevision 5
*/
forceDimensionMode(): void;
/**
* Utility method for executing setDimensionMode({@link DimensionMode#OFF}).
* @since Sitevision 5
*/
clearDimensionMode(): void;
/**
* Utility method for executing setDimensionMode({@link DimensionMode#AUTO}).
* @since Sitevision 5
*/
resetDimensionMode(): void;
/**
* The fetchpriority attribute rendering strategy.
* * Default is {@link FetchPriorityMode#OFF}. The attribute should be used sparingly, as excessive or incorrect prioritization can * degrade performance. See MDN Web Docs * for more information. *
* @param aFetchPriorityMode the fetch priority mode, determines whether and how afetchpriority attribute is rendered.
A null value will be completely ignored, use {@link FetchPriorityMode#OFF} to disable fetch priority.
* @since Sitevision 2026.10.1
*/
setFetchPriorityMode(aFetchPriorityMode: FetchPriorityMode): void;
/**
* Utility method for executing setFetchPriorityMode({@link FetchPriorityMode#HIGH}).
* @see #setFetchPriorityMode(FetchPriorityMode)
* @since Sitevision 2026.10.1
*/
setFetchPriorityHigh(): void;
/**
* Utility method for executing setFetchPriorityMode({@link FetchPriorityMode#LOW}).
* @see #setFetchPriorityMode(FetchPriorityMode)
* @since Sitevision 2026.10.1
*/
setFetchPriorityLow(): void;
/**
* Utility method for executing setFetchPriorityMode({@link FetchPriorityMode#AUTO}).
* @see #setFetchPriorityMode(FetchPriorityMode)
* @since Sitevision 2026.10.1
*/
setFetchPriorityAuto(): void;
/**
* Utility method for executing setFetchPriorityMode({@link FetchPriorityMode#OFF}).
* @see #setFetchPriorityMode(FetchPriorityMode)
* @since Sitevision 2026.10.1
*/
clearFetchPriorityMode(): void;
/**
* A title strategy that makes it possible to render a title attribute with the description as value.
* If titleRendering is disabled, no title attribute will be rendered at all. If titleRendering is
* enabled, the renderer will always render a title attribute and the descripton will be used as value.
*
* Default is false.
*
setUseTitleRendering(true)
* @see #setUseTitleRendering(boolean)
* @since Sitevision 2.6.2_04
*/
forceUseTitleRendering(): void;
/**
* Utility method for executing setUseTitleRendering(false)
* @see #setUseTitleRendering(boolean)
* @since Sitevision 2.6.2_04
*/
clearUseTitleRendering(): void;
/**
* A title fallback strategy that makes it possible to render a title value even if no description is available.
* When autoTitle is enabled, the renderer will try to use the image description metadata as title value if no description is available.
*
* Default is false.
*
* Note!
* This setting would typically be activated only if the title should be rendered (useTitleRendering
* is true) and the autoDescription is not activated (useAutoDescription is false).
* Remember - the title value is always the description, so any other cases than previously stated won't actually add anything new
* to your code/output...
*
setUseAutoTitle(true)
* @see #setUseAutoTitle(boolean)
* @since Sitevision 2.6.2_04
*/
forceUseAutoTitle(): void;
/**
* Utility method for executing setUseAutoTitle(false)
* @see #setUseAutoTitle(boolean)
* @since Sitevision 2.6.2_04
*/
clearUseAutoTitle(): void;
/**
* Sets the image description (alt attribute on the img element).
* If there are no description (i.e. description is null) when the result is rendered, an empty alt attribute will be rendered
* unless the useAutoDescription feature is active (see {@link #setUseAutoDescription(boolean)}).
*
* Default is null.
*
setDescription(null)
* @see #setDescription(String)
*/
clearDescription(): void;
/**
* Sets the style (style attribute on the img element).
* If there are no style (i.e. style is null) when the result is rendered, no style attribute will be rendered
*
* Default is border:none.
*
setStyle(null)
* @see #setStyle(String)
* @since Sitevision 2.6.1_10
*/
clearStyle(): void;
/**
* Sets whether or not descriptions should be encoded.
*
* Default is true.
*
setUseEncoding(true)
* @see #setUseEncoding(boolean)
*/
forceUseEncoding(): void;
/**
* Utility method for executing setUseEncoding(false)
* @see #setUseEncoding(boolean)
*/
clearUseEncoding(): void;
/**
* Sets whether or not the image should be lazy loaded (loaded when it appears in the browser's viewport).
*
* Note! Lazy loading depends on JavaScript being enabled.
* Be sure to include an img in a noscript-tag for non JavaScript users.
*
* Default is false.
*
setLazyLoad(true)
* @see #setLazyLoad(boolean)
* @since Sitevision 5.0
*/
forceUseLazyLoad(): void;
/**
* Utility method for executing setLazyLoad(false)
* @see #setLazyLoad(boolean)
* @since Sitevision 5.0
*/
clearUseLazyLoad(): void;
/**
* Adds an HTML5 data-* attribute to the image element.
* Data attributes are optional when the result is rendered. Default is no data attributes.
* * There can only be one data attribute per name (i.e. when a data attribute is added it will always replace the possibly existing * data attribute that already use that name). *
* ** Notes about names and values: *
*null or whitespace-only will be completely ignored,
* i.e. no data attribute will be rendered.
* null or whitespace-only will be rendered as a data attribute without value.
* * There can only be one aria attribute per name (i.e. when an aria attribute is added it will always replace the possibly existing * aria attribute that already use that name). *
* ** Notes about names and values: *
*null or whitespace-only will be completely ignored,
* i.e. no aria attribute will be rendered.
* null or whitespace-only will be rendered as an aria attribute without value.
* * Notes about css classes: *
*null or whitespace-only will be completely ignored,
* i.e. no css class will be added to the class attribute.
* * Note! The render method is not thread safe (see thread note above) * and not all image types can be rendered when using an image scaler (see image support note above). *
* @return if the renderer has a loaded image a html img element, ready to print out on a page, will be returned. If there are no image to render or rendering fails, an empty string will be returned. */ render(): string; } declare namespace ImageRenderer {} declare var imageRenderer: ImageRenderer; export default imageRenderer;