CoolCMS API

InitTrait

Table of Contents

Methods

imagesToGalleryArray()  : array<int, Asset, src: string, thumb: string, poster: string|null, caption: string|null, alt: string, isVideo: bool, mime: string, placeholder: string, isPlaceholder: bool, sources: array}>
Converts Asset entities to the array format expected by Gallery templates.

Methods

imagesToGalleryArray()

Converts Asset entities to the array format expected by Gallery templates.

public imagesToGalleryArray(array<string|int, Asset|null> $assets) : array<int, Asset, src: string, thumb: string, poster: string|null, caption: string|null, alt: string, isVideo: bool, mime: string, placeholder: string, isPlaceholder: bool, sources: array}>

Variants are sorted ascending by maxWidth so the smallest is thumb, the largest is src. Sources array contains all variants for use. Falls back to getFullPath() only when no variants exist (data integrity issue).

For video src is the mp4/mov in the base path; thumb/poster come from the image variant (only if one exists after ffmpeg).

A missing file (typically an asset from the shared database whose file exists only on the dev server) is replaced by a placeholder image, see AssetPlaceholderHelper. Templates put placeholder into data-asset-fallback so that the client asset-fallback.js also catches what the server cannot detect (404, file outside the web).

Parameters
$assets : array<string|int, Asset|null>

empty slots (deleted image) are skipped

Return values
array<int, Asset, src: string, thumb: string, poster: string|null, caption: string|null, alt: string, isVideo: bool, mime: string, placeholder: string, isPlaceholder: bool, sources: array}>
On this page

Search results