Skip to content
PHP Ecosystem
Explore

Image

API reference › HTML SVG › Image

Represents the SVG <image> (image) element for embedding bitmap images.

Provides a concrete <image> element implementation that returns SvgVoid::IMAGE and provides linking, geometry, presentation, and transform attribute methods.

The <image> element embeds an external image into the SVG.

See also: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/image (BaseVoid for the base implementation.).

PropertyTypeDescriptionDefined by
$attributes protectedmixed[]HTML attributes array used by the implementing class. Default: [].UIAwesome\Html\Mixin\HasAttributes
MethodDescriptionDefined by
__construct() finalInitializes a new tag instance.UIAwesome\Html\Core\Base\BaseTag
__toString()Returns the rendered tag string.UIAwesome\Html\Core\Base\BaseTag
accesskey()Sets the accesskey attribute.UIAwesome\Html\Attribute\Global\HasAccesskey
addAriaAttribute()Sets an aria-* attribute.UIAwesome\Html\Attribute\Global\HasAria
addAttribute()Adds or updates a single HTML attribute for the element.UIAwesome\Html\Mixin\HasAttributes
addDataAttribute()Sets a data-* attribute.UIAwesome\Html\Attribute\Global\HasData
addEvent()Sets an on* event attribute.UIAwesome\Html\Attribute\Global\HasEvents
ariaAttributes()Sets multiple aria-* attributes.UIAwesome\Html\Attribute\Global\HasAria
attributes()Adds or updates multiple HTML attributes for the element.UIAwesome\Html\Mixin\HasAttributes
class()Sets the class attribute.UIAwesome\Html\Attribute\Global\HasClass
config()Applies application-scoped config recipes to this tag.UIAwesome\Html\Core\Base\BaseTag
dataAttributes()Sets multiple data-* attributes.UIAwesome\Html\Attribute\Global\HasData
decoding()Sets the decoding attribute.Image
dir()Sets the dir attribute.UIAwesome\Html\Attribute\Global\HasDir
events()Sets multiple on* event attributes.UIAwesome\Html\Attribute\Global\HasEvents
fetchpriority()Sets the fetchpriority attribute.Image
getAttribute()Returns the value of a single HTML attribute.UIAwesome\Html\Mixin\HasAttributes
getAttributes()Returns the array of HTML attributes for the element.UIAwesome\Html\Mixin\HasAttributes
height()Sets the height attribute.Image
hidden()Sets the hidden attribute.UIAwesome\Html\Attribute\Global\CanBeHidden
href()Sets the href attribute.Image
id()Sets the id attribute.UIAwesome\Html\Attribute\Global\HasId
lang()Sets the lang attribute.UIAwesome\Html\Attribute\Global\HasLang
opacity()Sets the SVG opacity attribute for the element.Image
preserveAspectRatio()Sets the SVG preserveAspectRatio attribute for the element.Image
removeAriaAttribute()Removes an aria-* attribute.UIAwesome\Html\Attribute\Global\HasAria
removeAttribute()Removes a specific HTML attribute from the element.UIAwesome\Html\Mixin\HasAttributes
removeDataAttribute()Removes a data-* attribute.UIAwesome\Html\Attribute\Global\HasData
removeEvent()Removes an on* event attribute.UIAwesome\Html\Attribute\Global\HasEvents
render() finalRenders the tag with lifecycle hooks.UIAwesome\Html\Core\Base\BaseTag
replaceAttributes()Replaces all HTML attributes for the element.UIAwesome\Html\Mixin\HasAttributes
role()Sets the role attribute.UIAwesome\Html\Attribute\Global\HasRole
style()Sets the style attribute.UIAwesome\Html\Attribute\Global\HasStyle
tag() staticCreates and configures a new tag instance.UIAwesome\Html\Core\Base\BaseTag
title()Sets the title attribute.UIAwesome\Html\Attribute\Global\HasTitle
transform()Sets the SVG transform attribute for the element.Image
translate()Sets the translate attribute.UIAwesome\Html\Attribute\Global\HasTranslate
width()Sets the width attribute.Image
x()Sets the SVG x attribute for the element.Image
y()Sets the SVG y attribute for the element.Image
afterRun() protectedPost-processes rendered output.UIAwesome\Html\Core\Event\HasAfterRun
beforeRun() protectedValidates state before rendering.UIAwesome\Html\Core\Event\HasBeforeRun
getTag() protectedReturns the tag enumeration for the <image> element.Image
loadDefault() protectedReturns class-level default definitions.UIAwesome\Html\Core\Base\BaseTag
run() protectedRenders the void element.UIAwesome\Html\Core\Element\BaseVoid
public function decoding(string|Stringable|UnitEnum|null $value): static

Sets the decoding attribute.

Usage example:

$element->decoding('async');
$element->decoding(Decoding::ASYNC);
$element->decoding(null);

Parameters

ParameterTypeDescription
$valuestring|Stringable|UnitEnum|nullDecoding hint value. Use ‘async’, ‘sync’, or ‘auto’, or null to remove the attribute.

Returns

static: New instance with the updated decoding attribute. Decoding for predefined enum values.

public function fetchpriority(string|UnitEnum|null $value): static

Sets the fetchpriority attribute.

Usage example:

$element->fetchpriority('high');
$element->fetchpriority(Fetchpriority::HIGH);
$element->fetchpriority(null);

Parameters

ParameterTypeDescription
$valuestring|UnitEnum|nullFetch priority token, or null to remove the attribute.

Returns

static: New instance with the updated fetchpriority attribute. Fetchpriority for predefined enum values.

public function height(int|string|Stringable|UnitEnum|null $value): static

Sets the height attribute.

Usage example:

$element->height(200);
$element->height('50%');
$element->height('auto');

Parameters

ParameterTypeDescription
$valueint|string|Stringable|UnitEnum|nullHeight value in pixels or CSS units, or null to remove the attribute.

Returns

static: New instance with the updated height attribute.

public function href(string|Stringable|UnitEnum|null $value): static

Sets the href attribute.

Usage example:

$element->href('https://example.com/image.png');
$element->href('#image');
$element->href(null);

Parameters

ParameterTypeDescription
$valuestring|Stringable|UnitEnum|nullURL, path, or fragment, or null to remove the attribute.

Returns

static: New instance with the updated href attribute.

public function opacity(float|int|string|null $value): static

Sets the SVG opacity attribute for the element.

Creates a new instance with the specified opacity value for the rendered element.

Parameters

ParameterTypeDescription
$valuefloat|int|string|nullOpacity value (for example, ‘0.5’ or null to unset).

Returns

static: New instance with the updated opacity attribute.

Throws

public function preserveAspectRatio(UIAwesome\Html\Svg\Values\PreserveAspectRatio|string|null $value): static

Sets the SVG preserveAspectRatio attribute for the element.

Creates a new instance with the specified preserve aspect ratio value for the rendered element.

Parameters

ParameterTypeDescription
$valueUIAwesome\Html\Svg\Values\PreserveAspectRatio|string|nullPreserve aspect ratio value (for example, ‘xMidYMid meet’, PreserveAspectRatio enum, or null to unset).

Returns

static: New instance with the updated preserveAspectRatio attribute.

Throws

public function transform(string|null $value): static

Sets the SVG transform attribute for the element.

Creates a new instance with the specified transform value for the rendered element.

Parameters

ParameterTypeDescription
$valuestring|nullTransform value (for example, ‘rotate(45)’, ‘scale(2)’, or null to unset).

Returns

static: New instance with the updated transform attribute.

public function width(int|string|Stringable|UnitEnum|null $value): static

Sets the width attribute.

Usage example:

$element->width(400);
$element->width('50%');
$element->width('auto');
$element->width(null);

Parameters

ParameterTypeDescription
$valueint|string|Stringable|UnitEnum|nullWidth value in pixels or CSS units, or null to remove the attribute.

Returns

static: New instance with the updated width attribute.

public function x(float|int|string|null $value): static

Sets the SVG x attribute for the element.

Creates a new instance with the specified x-coordinate value for the rendered element.

Parameters

ParameterTypeDescription
$valuefloat|int|string|nullX coordinate value (for example, ‘10’, ‘10.3’, ‘50%’, or null to unset).

Returns

static: New instance with the updated x attribute.

public function y(float|int|string|null $value): static

Sets the SVG y attribute for the element.

Creates a new instance with the specified y-coordinate value for the rendered element.

Parameters

ParameterTypeDescription
$valuefloat|int|string|nullY coordinate value (for example, ‘20’, ‘10.3’, ‘50%’, or null to unset).

Returns

static: New instance with the updated y attribute.

protected function getTag(): BackedEnum

Returns the tag enumeration for the <image> element.

Returns

BackedEnum: Tag enumeration instance for <image>. SvgVoid for valid SVG void-level tags.