From c62b259e53b3b474587764eac978beec4992cd4f Mon Sep 17 00:00:00 2001 From: torleif Date: Wed, 29 Jun 2022 10:52:45 +1200 Subject: [PATCH] Update RetinaImageExtension.php --- src/RetinaImageExtension.php | 70 ++++++++++++++---------------------- 1 file changed, 27 insertions(+), 43 deletions(-) diff --git a/src/RetinaImageExtension.php b/src/RetinaImageExtension.php index f71de76..2ca0993 100644 --- a/src/RetinaImageExtension.php +++ b/src/RetinaImageExtension.php @@ -43,13 +43,12 @@ public function RetinaFill($width, $height) return $this->owner->Fill($width, $height); } - return HTML::createTag('img', [ - 'alt' => $this->owner->Title, + return HTML::createTag('img', array_merge($img1->getAttributes(), [ 'src' => $img1->getURL(), 'srcset' => $img1->getURL() . ' 1x, ' . $img2->getURL() . ' 1.5x,' . $img3->getURL() . ' 2x' - ]); + ])); } - + /** * @param int $width * @param int $height @@ -65,16 +64,17 @@ public function RetinaFillMax($width, $height) return $this->owner->FillMax($width, $height); } - return HTML::createTag('img', [ - 'alt' => $this->owner->Title, + return HTML::createTag('img', array_merge($img1->getAttributes(), [ 'src' => $img1->getURL(), 'srcset' => $img1->getURL() . ' 1x, ' . $img2->getURL() . ' 1.5x,' . $img3->getURL() . ' 2x' - ]); + ])); } /** * @param int $width * @param int $height + * @param string $backgroundColor + * @param float $transparencyPercent * @return html */ public function RetinaPad($width, $height, $backgroundColor = 'FFFFFF', $transparencyPercent = 0) @@ -87,11 +87,10 @@ public function RetinaPad($width, $height, $backgroundColor = 'FFFFFF', $transpa return $this->owner->Pad($width, $height, $backgroundColor, $transparencyPercent); } - return HTML::createTag('img', [ - 'alt' => $this->owner->Title, + return HTML::createTag('img', array_merge($img1->getAttributes(), [ 'src' => $img1->getURL(), 'srcset' => $img1->getURL() . ' 1x, ' . $img2->getURL() . ' 1.5x,' . $img3->getURL() . ' 2x' - ]); + ])); } /** @@ -109,11 +108,10 @@ public function RetinaFitMax($width, $height) return $this->owner->FitMax($width, $height); } - return HTML::createTag('img', [ - 'alt' => $this->owner->Title, + return HTML::createTag('img', array_merge($img1->getAttributes(), [ 'src' => $img1->getURL(), 'srcset' => $img1->getURL() . ' 1x, ' . $img2->getURL() . ' 1.5x,' . $img3->getURL() . ' 2x' - ]); + ])); } /** @@ -131,11 +129,10 @@ public function RetinaResizedImage($width, $height) return $this->owner->ResizedImage($width, $height); } - return HTML::createTag('img', [ - 'alt' => $this->owner->Title, + return HTML::createTag('img', array_merge($img1->getAttributes(), [ 'src' => $img1->getURL(), 'srcset' => $img1->getURL() . ' 1x, ' . $img2->getURL() . ' 1.5x,' . $img3->getURL() . ' 2x' - ]); + ])); } /** * @param int $width @@ -152,16 +149,14 @@ public function RetinaFit($width, $height) return $this->owner->Fit($width, $height); } - return HTML::createTag('img', [ - 'alt' => $this->owner->Title, + return HTML::createTag('img', array_merge($img1->getAttributes(), [ 'src' => $img1->getURL(), 'srcset' => $img1->getURL() . ' 1x, ' . $img2->getURL() . ' 1.5x,' . $img3->getURL() . ' 2x' - ]); + ])); } /** * @param int $width - * @param int $height * @return html */ public function RetinaCropWidth($width) @@ -174,16 +169,14 @@ public function RetinaCropWidth($width) return $this->owner->CropWidth($width); } - return HTML::createTag('img', [ - 'alt' => $this->owner->Title, + return HTML::createTag('img', array_merge($img1->getAttributes(), [ 'src' => $img1->getURL(), 'srcset' => $img1->getURL() . ' 1x, ' . $img2->getURL() . ' 1.5x,' . $img3->getURL() . ' 2x' - ]); + ])); } /** * @param int $width - * @param int $height * @return html */ public function RetinaCropHeight($width) @@ -196,16 +189,14 @@ public function RetinaCropHeight($width) return $this->owner->CropHeight($width); } - return HTML::createTag('img', [ - 'alt' => $this->owner->Title, + return HTML::createTag('img', array_merge($img1->getAttributes(), [ 'src' => $img1->getURL(), 'srcset' => $img1->getURL() . ' 1x, ' . $img2->getURL() . ' 1.5x,' . $img3->getURL() . ' 2x' - ]); + ])); } /** * @param int $width - * @param int $height * @return html */ public function RetinaScaleWidth($width) @@ -218,16 +209,14 @@ public function RetinaScaleWidth($width) return $this->owner->ScaleWidth($width); } - return HTML::createTag('img', [ - 'alt' => $this->owner->Title, + return HTML::createTag('img', array_merge($img1->getAttributes(), [ 'src' => $img1->getURL(), 'srcset' => $img1->getURL() . ' 1x, ' . $img2->getURL() . ' 1.5x,' . $img3->getURL() . ' 2x' - ]); + ])); } /** * @param int $width - * @param int $height * @return html */ public function RetinaScaleMaxWidth($width) @@ -240,16 +229,14 @@ public function RetinaScaleMaxWidth($width) return $this->owner->ScaleMaxWidth($width); } - return HTML::createTag('img', [ - 'alt' => $this->owner->Title, + return HTML::createTag('img', array_merge($img1->getAttributes(), [ 'src' => $img1->getURL(), 'srcset' => $img1->getURL() . ' 1x, ' . $img2->getURL() . ' 1.5x,' . $img3->getURL() . ' 2x' - ]); + ])); } /** * @param int $width - * @param int $height * @return html */ public function RetinaScaleMaxHeight($width) @@ -262,16 +249,14 @@ public function RetinaScaleMaxHeight($width) return $this->owner->ScaleMaxHeight($width); } - return HTML::createTag('img', [ - 'alt' => $this->owner->Title, + return HTML::createTag('img', array_merge($img1->getAttributes(), [ 'src' => $img1->getURL(), 'srcset' => $img1->getURL() . ' 1x, ' . $img2->getURL() . ' 1.5x,' . $img3->getURL() . ' 2x' - ]); + ])); } /** * @param int $width - * @param int $height * @return html */ public function RetinaScaleHeight($width) @@ -284,10 +269,9 @@ public function RetinaScaleHeight($width) return $this->owner->ScaleHeight($width); } - return HTML::createTag('img', [ - 'alt' => $this->owner->Title, + return HTML::createTag('img', array_merge($img1->getAttributes(), [ 'src' => $img1->getURL(), 'srcset' => $img1->getURL() . ' 1x, ' . $img2->getURL() . ' 1.5x,' . $img3->getURL() . ' 2x' - ]); + ])); } }