Data Transfer Objects
New in version 13.1.5
DTOs provide type-safe data contracts between services.
Data Transfer Objects (DTOs) encapsulate validated, sanitized data for image rendering.
They are immutable (
readonly) to ensure data integrity throughout the rendering pipeline.
Table of contents
ImageRenderingDto
- class ImageRenderingDto
-
- Fully qualified name
-
\Netresearch\
Rte CKEditor Image\ Domain\ Model\ Image Rendering Dto
Type-safe container for all image rendering data.
Important
All security validation MUST occur in
Image before DTO construction.
The DTO represents validated, sanitized data ready for presentation.
Properties
final readonly class ImageRenderingDto
{
public function __construct(
public string $src, // Image source URL (validated)
public int $width, // Display width in pixels
public int $height, // Display height in pixels
public ?string $alt, // Alternative text for accessibility
public ?string $title, // Title attribute for hover tooltip
public array $htmlAttributes, // Additional HTML attributes
public ?string $caption, // Caption text (XSS-sanitized)
public ?LinkDto $link, // Link/popup configuration
public bool $isMagicImage, // Whether TYPO3 processing enabled
) {}
}
Property details
src
-
- Type
- string
- Required
true
The processed image URL. Always validated and safe for output.
width
-
- Type
- int
- Required
true
Display width in pixels. Used for proper aspect ratio and layout.
height
-
- Type
- int
- Required
true
Display height in pixels. Used for proper aspect ratio and layout.
alt
-
- Type
- ?string
Alternative text for accessibility (screen readers, broken images).
title
-
- Type
- ?string
Title attribute shown as tooltip on hover.
htmlAttributes
-
- Type
- array<string,mixed>
- Required
true
Additional HTML attributes such as:
class: CSS classes.style: Inline styles.loading: Lazy loading setting (lazy,eager).data-*: Custom data attributes.
caption
-
- Type
- ?string
Caption text for
<figcaption>. Already sanitized withhtmlspecialchars.()
link
-
- Type
- ?LinkDto
Link or popup configuration. See LinkDto.
isMagicImage
-
- Type
- bool
- Required
true
Indicates whether TYPO3 image processing (magic images) was applied.
LinkDto
- class LinkDto
-
- Fully qualified name
-
\Netresearch\
Rte CKEditor Image\ Domain\ Model\ Link Dto
Encapsulates link/popup configuration for linked images.
Properties
final readonly class LinkDto
{
public function __construct(
public string $url, // Link URL (validated)
public ?string $target, // Link target (_blank, _self, etc.)
public ?string $class, // CSS class for link element
public bool $isPopup, // Whether this is a popup/lightbox link
public ?array $jsConfig, // JavaScript configuration for lightbox
) {}
}
Property details
url
-
- Type
- string
- Required
true
The link target URL. Validated against dangerous protocols.
target
-
- Type
- ?string
Link target attribute (
_blank,_self,_parent,_top).
class
-
- Type
- ?string
CSS classes applied to the
<a>element.
isPopup
-
- Type
- bool
- Required
true
Whether the link should open in a popup/lightbox instead of navigating.
jsConfig
-
- Type
- ?array<string,mixed>
JavaScript configuration for lightbox/popup behavior:
Example jsConfig structure[ 'width' => 800, 'height' => 600, 'effect' => 'fade' ]Copied!
Usage example
use Netresearch\RteCKEditorImage\Domain\Model\ImageRenderingDto;
use Netresearch\RteCKEditorImage\Domain\Model\LinkDto;
// Create link DTO for popup
$link = new LinkDto(
url: '/fileadmin/images/large.jpg',
target: null,
class: 'lightbox',
isPopup: true,
jsConfig: ['effect' => 'fade']
);
// Create image DTO
$image = new ImageRenderingDto(
src: '/fileadmin/_processed_/image_hash.jpg',
width: 800,
height: 600,
alt: 'Example image',
title: 'Click to enlarge',
htmlAttributes: ['class' => 'img-responsive', 'loading' => 'lazy'],
caption: 'Photo by Photographer',
link: $link,
isMagicImage: true
);
// DTOs are immutable - properties cannot be changed
// $image->width = 1000; // Error: Cannot modify readonly property