url($url); $this->alt($alt); } public static function make(string | Closure $url, string | Closure $alt): static { $static = app(static::class, ['url' => $url, 'alt' => $alt]); $static->configure(); return $static; } public function url(string | Closure $url): static { // Security: If this URL is derived from user input, validate it // to prevent XSS via `javascript:` protocol URLs rendered // in `src` attributes. $this->url = $url; return $this; } public function getUrl(): string { return $this->evaluate($this->url); } public function alt(string | Closure $alt): static { $this->alt = $alt; return $this; } public function getAlt(): string { return $this->evaluate($this->alt); } public function imageHeight(int | string | Closure | null $height): static { $this->imageHeight = $height; return $this; } public function imageSize(int | string | Closure $size): static { $this->imageWidth($size); $this->imageHeight($size); return $this; } public function imageWidth(int | string | Closure | null $width): static { $this->imageWidth = $width; return $this; } public function getImageHeight(): ?string { $height = $this->evaluate($this->imageHeight); if ($height === null) { return null; } if (is_int($height)) { return "{$height}px"; } return $height; } public function getImageWidth(): ?string { $width = $this->evaluate($this->imageWidth); if ($width === null) { return null; } if (is_int($width)) { return "{$width}px"; } return $width; } public function toEmbeddedHtml(): string { $alignment = $this->getAlignment(); $height = $this->getImageHeight() ?? '8rem'; $width = $this->getImageWidth(); $tooltip = $this->getTooltip(); if (! $alignment instanceof Alignment) { $alignment = filled($alignment) ? (Alignment::tryFrom($alignment) ?? $alignment) : null; } $attributes = $this->getExtraAttributeBag() ->class([ 'fi-sc-image', ($alignment instanceof Alignment) ? "fi-align-{$alignment->value}" : $alignment, ]) ->style([ ('height: ' . e($height)) => $height, ('width: ' . e($width)) => $width, ]); ob_start(); ?> <?= e($this->getAlt()) ?> x-tooltip="{ content: , theme: $store.theme, allowHTML: }" toHtml() ?> />