Skip to content

Commit

Permalink
fix: Fixed an issue where an exception could be thrown using the defa…
Browse files Browse the repository at this point in the history
…ult "shortcut" syntax due to a regression ([#422](#422))
  • Loading branch information
khalwat committed Feb 13, 2025
1 parent c863842 commit c232f10
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 25 deletions.
14 changes: 3 additions & 11 deletions src/models/ImgTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class ImgTag extends BaseImageTag
public array $imgAttrs = [];

/**
* @param $config
* @inheritDoc
*/
public function __construct($config = [])
public function init(): void
{
parent::__construct($config);
parent::init();
// Populate the $imageAttrs
$this->imgAttrs = [
'class' => '',
Expand All @@ -53,14 +53,6 @@ public function __construct($config = [])
'sizes' => '100vw',
'loading' => '',
];
}

/**
* @inheritDoc
*/
public function init(): void
{
parent::init();
// If the original image is an SVG or gif, don't add the placeholder box CSS so that transparency works as intended
$path = parse_url($this->imgAttrs['src'], PHP_URL_PATH);
$extension = pathinfo($path, PATHINFO_EXTENSION);
Expand Down
6 changes: 3 additions & 3 deletions src/models/LinkPreloadTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class LinkPreloadTag extends BaseTag
public array $linkAttrs = [];

/**
* @param $config
* @inheritDoc
*/
public function __construct($config = [])
public function init(): void
{
parent::__construct($config);
parent::init();
// Any web browser that supports link rel="preload" as="image" also supports webp, so prefer that
$srcset = $this->optimizedImage->optimizedImageUrls;
if (!empty($this->optimizedImage->optimizedWebPImageUrls)) {
Expand Down
14 changes: 3 additions & 11 deletions src/models/PictureTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ class PictureTag extends BaseImageTag
public array $imgAttrs = [];

/**
* @param $config
* @inheritDoc
*/
public function __construct($config = [])
public function init(): void
{
parent::__construct($config);
parent::init();
// Populate the $imageAttrs
$this->imgAttrs = [
'class' => '',
Expand All @@ -65,14 +65,6 @@ public function __construct($config = [])
$this->populateSourceAttrs($this->optimizedImage, []);
// Populate the $pictureAttrs
$this->pictureAttrs = [];
}

/**
* @inheritDoc
*/
public function init(): void
{
parent::init();
// If the original image is an SVG or gif, don't add the placeholder box CSS so that transparency works as intended
$path = parse_url($this->imgAttrs['src'], PHP_URL_PATH);
$extension = pathinfo($path, PATHINFO_EXTENSION);
Expand Down

0 comments on commit c232f10

Please sign in to comment.