diff --git a/src/models/PictureTag.php b/src/models/PictureTag.php index 0402eabc..01027d91 100644 --- a/src/models/PictureTag.php +++ b/src/models/PictureTag.php @@ -37,9 +37,9 @@ class PictureTag extends BaseImageTag public $pictureAttrs = []; /** - * @var array array of tag attributes for the tag + * @var array array of tag attributes for the tags */ - public $srcsetAttrs = []; + public $sourceAttrs = []; /** * @var array array of tag attributes for the tag @@ -66,8 +66,8 @@ public function __construct($config = []) 'src' => reset($this->optimizedImage->optimizedImageUrls), 'loading' => '', ]; - // Populate the $srcsetAttrs - $this->populateSrcsetAttrs($this->optimizedImage, []); + // Populate the $sourceAttrs + $this->populateSourceAttrs($this->optimizedImage, []); // Populate the $pictureAttrs $this->pictureAttrs = []; } @@ -112,14 +112,14 @@ public function pictureAttrs(array $value): PictureTag } /** - * Merge the passed array of tag attributes into $srcsetAttrs + * Merge the passed array of tag attributes into $sourceAttrs * * @param array $value * @return $this */ - public function srcsetAttrs(array $value): PictureTag + public function sourceAttrs(array $value): PictureTag { - foreach ($this->srcsetAttrs as &$attrs) { + foreach ($this->sourceAttrs as &$attrs) { $attrs = array_merge($attrs, $value); } unset($attrs); @@ -141,15 +141,15 @@ public function imgAttrs(array $value): PictureTag } /** - * Add art direction srcsets to the $srcsetAttrs + * Add art direction sources to the $sourceAttrs * * @param OptimizedImage $optimizedImage - * @param array $srcsetAttrs + * @param array $sourceAttrs * @return PictureTag */ - public function artDirection(OptimizedImage $optimizedImage, array $srcsetAttrs = []): PictureTag + public function artDirection(OptimizedImage $optimizedImage, array $sourceAttrs = []): PictureTag { - $this->populateSrcsetAttrs($optimizedImage, $srcsetAttrs); + $this->populateSourceAttrs($optimizedImage, $sourceAttrs); return $this; } @@ -162,8 +162,8 @@ public function artDirection(OptimizedImage $optimizedImage, array $srcsetAttrs public function render(): Markup { $content = ''; - // Handle the tag(s) - foreach ($this->srcsetAttrs as $attrs) { + // Handle the tag(s) + foreach ($this->sourceAttrs as $attrs) { // Handle lazy loading if ($this->loading !== 'eager') { $attrs = $this->swapLazyLoadAttrs($this->loading, $this->placeholder, $attrs); @@ -194,30 +194,30 @@ public function render(): Markup } /** - * Populate the $srcsetAttrs from the passed in $optimizedImage and $sizes + * Populate the $sourceAttrs from the passed in $optimizedImage and $sizes * * @param OptimizedImage $optimizedImage - * @param array $srcsetAttrs attributes to add to the $srcsetAttrs array + * @param array $sourceAttrs attributes to add to the $sourceAttrs array * @return void */ - protected function populateSrcsetAttrs(OptimizedImage $optimizedImage, array $srcsetAttrs): void + protected function populateSourceAttrs(OptimizedImage $optimizedImage, array $sourceAttrs): void { if (!empty($optimizedImage->optimizedWebPImageUrls)) { - $this->srcsetAttrs[] = array_merge([ + $this->sourceAttrs[] = array_merge([ 'media' => '', 'srcset' => $optimizedImage->getSrcsetFromArray($optimizedImage->optimizedWebPImageUrls), 'type' => 'image/webp', 'sizes' => '100vw', 'width' => $optimizedImage->placeholderWidth, 'height' => $optimizedImage->placeholderHeight, - ], $srcsetAttrs); + ], $sourceAttrs); } - $this->srcsetAttrs[] = array_merge([ + $this->sourceAttrs[] = array_merge([ 'media' => '', 'srcset' => $optimizedImage->getSrcsetFromArray($optimizedImage->optimizedImageUrls), 'sizes' => '100vw', 'width' => $optimizedImage->placeholderWidth, 'height' => $optimizedImage->placeholderHeight, - ], $srcsetAttrs); + ], $sourceAttrs); } }