Skip to content
PHP Ecosystem
Explore

Img

API reference › HTML › Embedded › Img

Renders the HTML <img> element for embedding images.

Supports the experimental elementtiming attribute. Availability and behavior may vary across browsers.

See also: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img (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
alt()Sets the alt attribute.Img
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
crossorigin()Sets the crossorigin attribute.UIAwesome\Html\Attribute\HasCrossorigin
dataAttributes()Sets multiple data-* attributes.UIAwesome\Html\Attribute\Global\HasData
decoding()Sets the decoding attribute.Img
dir()Sets the dir attribute.UIAwesome\Html\Attribute\Global\HasDir
elementtiming()Sets the elementtiming attribute.Img
events()Sets multiple on* event attributes.UIAwesome\Html\Attribute\Global\HasEvents
fetchpriority()Sets the fetchpriority attribute.UIAwesome\Html\Attribute\HasFetchpriority
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.Img
hidden()Sets the hidden attribute.UIAwesome\Html\Attribute\Global\CanBeHidden
id()Sets the id attribute.UIAwesome\Html\Attribute\Global\HasId
ismap()Sets the ismap attribute.Img
lang()Sets the lang attribute.UIAwesome\Html\Attribute\Global\HasLang
loading()Sets the loading attribute.Img
referrerpolicy()Sets the referrerpolicy attribute.Img
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
sizes()Sets the sizes attribute.UIAwesome\Html\Attribute\HasSizes
src()Sets the src attribute.Img
srcset()Sets the srcset attribute.Img
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
translate()Sets the translate attribute.UIAwesome\Html\Attribute\Global\HasTranslate
usemap()Sets the usemap attribute.Img
width()Sets the width attribute.Img
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 <img> element.Img
loadDefault() protectedReturns class-level default definitions.UIAwesome\Html\Core\Base\BaseTag
run() protectedRenders the void element.UIAwesome\Html\Core\Element\BaseVoid
public function alt(string|Stringable|UnitEnum|null $value): static

Sets the alt attribute.

Parameters

ParameterTypeDescription
$valuestring|Stringable|UnitEnum|nullAlternative text for the element, or null to remove the attribute.

Returns

static: New instance with the updated alt attribute.

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

Sets the decoding attribute.

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.

Throws

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

Sets the elementtiming attribute.

Parameters

ParameterTypeDescription
$valuestring|UnitEnum|nullElement timing identifier, or null to remove the attribute.

Returns

static: New instance with the updated elementtiming attribute.

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

Sets the height attribute.

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 ismap(bool $value): static

Sets the ismap attribute.

Parameters

ParameterTypeDescription
$valueboolWhether the image is a server-side image map.

Returns

static: New instance with the updated ismap attribute.

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

Sets the loading attribute.

Parameters

ParameterTypeDescription
$valuestring|Stringable|UnitEnum|nullLoading strategy (‘eager’ or ‘lazy’), or null to remove the attribute.

Returns

static: New instance with the updated loading attribute. Loading for predefined enum values.

Throws

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

Sets the referrerpolicy attribute.

Parameters

ParameterTypeDescription
$valuestring|Stringable|UnitEnum|nullReferrer policy token, or null to remove the attribute.

Returns

static: New instance with the updated referrerpolicy attribute. Referrerpolicy for predefined enum values.

Throws

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

Sets the src attribute.

Parameters

ParameterTypeDescription
$valuestring|Stringable|UnitEnum|nullImage source URL or path, or null to remove the attribute.

Returns

static: New instance with the updated src attribute.

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

Sets the srcset attribute.

Parameters

ParameterTypeDescription
$valuestring|Stringable|UnitEnum|nullComma-separated image URLs with size descriptors, or null to remove the attribute.

Returns

static: New instance with the updated srcset attribute.

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

Sets the usemap attribute.

Parameters

ParameterTypeDescription
$valuestring|Stringable|UnitEnum|nullHash-name reference to a map element, or null to remove the attribute.

Returns

static: New instance with the updated usemap attribute.

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

Sets the width attribute.

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.

protected function getTag(): UIAwesome\Html\Interop\Voids

Returns the tag enumeration for the <img> element.

Returns

Voids: Tag enumeration instance for <img>. Voids for valid void-level tags.