Skip to content

Commit 24b4113

Browse files
committed
Allow ImageRenderer::icon() to be passed full asset ID
1 parent a84b871 commit 24b4113

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

Util/Block/ImageRenderer.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,25 @@ public function icon(AbstractBlock $block, string $iconId, array $attributes = [
8383
{
8484
$this->block = $block;
8585
$iconSize = $this->getIconSize($iconId);
86-
$imageId = $this->iconPrefix
87-
. '/' . $this->iconSet
88-
. '/' . $iconId
89-
. '.svg';
86+
87+
if (preg_match('/^([A-Za-z0-9]+)::(.+)$/', $iconId)) {
88+
$iconId = $this->iconPrefix
89+
. '/' . $this->iconSet
90+
. '/' . $iconId
91+
. '.svg';
92+
}
9093

9194
$attributes = [
9295
...$attributes,
9396
'width' => $iconSize,
9497
'height' => $iconSize,
9598
];
9699

97-
if ($this->isAssetId($imageId)) {
98-
return $this->getByAssetId($imageId, $attributes);
100+
if ($this->isAssetId($iconId)) {
101+
return $this->getByAssetId($iconId, $attributes);
99102
}
100103

101-
return $this->getIconOutput($imageId, $attributes);
104+
return $this->getIconOutput($iconId, $attributes);
102105
}
103106

104107
public function getIconOutput(

0 commit comments

Comments
 (0)