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.).
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$attributes protected | mixed[] | HTML attributes array used by the implementing class. Default: []. | UIAwesome\ |
Methods
Section titled “Methods”Method details
Section titled “Method details”alt()
Section titled “alt() ”public function alt(string|Stringable|UnitEnum|null $value): staticSets the alt attribute.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | string|Stringable|UnitEnum| | Alternative text for the element, or null to remove the attribute. |
Returns
static: New instance with the updated alt attribute.
decoding()
Section titled “decoding() ”public function decoding(string|Stringable|UnitEnum|null $value): staticSets the decoding attribute.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | string|Stringable|UnitEnum| | Decoding 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
InvalidArgumentException: If the value is not valid.
elementtiming()
Section titled “elementtiming() ”public function elementtiming(string|UnitEnum|null $value): staticSets the elementtiming attribute.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | string|UnitEnum| | Element timing identifier, or null to remove the attribute. |
Returns
static: New instance with the updated elementtiming attribute.
height()
Section titled “height() ”public function height(int|string|Stringable|UnitEnum|null $value): staticSets the height attribute.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | int|Stringable|UnitEnum| | Height value in pixels or CSS units, or null to remove the attribute. |
Returns
static: New instance with the updated height attribute.
ismap()
Section titled “ismap() ”public function ismap(bool $value): staticSets the ismap attribute.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | bool | Whether the image is a server-side image map. |
Returns
static: New instance with the updated ismap attribute.
loading()
Section titled “loading() ”public function loading(string|Stringable|UnitEnum|null $value): staticSets the loading attribute.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | string|Stringable|UnitEnum| | Loading 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
InvalidArgumentException: If the value is not valid.
referrerpolicy()
Section titled “referrerpolicy() ”public function referrerpolicy(string|Stringable|UnitEnum|null $value): staticSets the referrerpolicy attribute.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | string|Stringable|UnitEnum| | Referrer policy token, or null to remove the attribute. |
Returns
static: New instance with the updated referrerpolicy attribute. Referrerpolicy for predefined enum values.
Throws
InvalidArgumentException: If the value is not valid.
src()
Section titled “src() ”public function src(string|Stringable|UnitEnum|null $value): staticSets the src attribute.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | string|Stringable|UnitEnum| | Image source URL or path, or null to remove the attribute. |
Returns
static: New instance with the updated src attribute.
srcset()
Section titled “srcset() ”public function srcset(string|Stringable|UnitEnum|null $value): staticSets the srcset attribute.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | string|Stringable|UnitEnum| | Comma-separated image URLs with size descriptors, or null to remove the attribute. |
Returns
static: New instance with the updated srcset attribute.
usemap()
Section titled “usemap() ”public function usemap(string|Stringable|UnitEnum|null $value): staticSets the usemap attribute.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | string|Stringable|UnitEnum| | Hash-name reference to a map element, or null to remove the attribute. |
Returns
static: New instance with the updated usemap attribute.
width()
Section titled “width() ”public function width(int|string|Stringable|UnitEnum|null $value): staticSets the width attribute.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | int|Stringable|UnitEnum| | Width value in pixels or CSS units, or null to remove the attribute. |
Returns
static: New instance with the updated width attribute.
getTag()
Section titled “getTag() ”protected function getTag(): UIAwesome\Html\Interop\VoidsReturns the tag enumeration for the <img> element.