From 5ff49bb81b234bf8d85e2467bf17c200aaeeac67 Mon Sep 17 00:00:00 2001 From: Patrick Boivin Date: Wed, 27 Oct 2021 16:50:31 -0400 Subject: [PATCH 1/3] Omit type attribute if webp_support is not active --- resources/views/picture.blade.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/views/picture.blade.php b/resources/views/picture.blade.php index 2358cff..277e7b8 100644 --- a/resources/views/picture.blade.php +++ b/resources/views/picture.blade.php @@ -6,7 +6,9 @@ @isset($sources) @foreach($sources as $source) Date: Wed, 27 Oct 2021 16:51:28 -0400 Subject: [PATCH 2/3] Omit srcWebp and srcSetWebp if webp_support is not active --- src/Services/MediaSource.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Services/MediaSource.php b/src/Services/MediaSource.php index a324737..d5a7fc8 100644 --- a/src/Services/MediaSource.php +++ b/src/Services/MediaSource.php @@ -291,7 +291,7 @@ protected function media() public function toArray() { - return [ + return array_merge([ "alt" => $this->alt(), "aspectRatio" => $this->aspectRatio(), "caption" => $this->caption(), @@ -302,10 +302,11 @@ public function toArray() "ratio" => $this->ratio(), "src" => $this->src(), "srcSet" => $this->srcSet(), + "width" => $this->width(), + ], (config('twill-image.webp_support') ? [ "srcWebp" => $this->srcWebp(), "srcSetWebp" => $this->srcSetWebp(), - "width" => $this->width(), - ]; + ] : [])); } /** From 048764c846b4247b104044592bb2c12c8ff0efac Mon Sep 17 00:00:00 2001 From: Patrick Boivin Date: Wed, 27 Oct 2021 16:53:57 -0400 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b2e1fb6..015b5b2 100644 --- a/README.md +++ b/README.md @@ -406,7 +406,7 @@ See [above section](#preset) about the `preset` method. |---|---|---|---| |`background_color`|`string`|`#e3e3e3`| | |`lqip`|`boolean`|`true`|Uses Twill LQIP method to generate responsive placeholder| -|`webp_support`|`boolean`|`true`| | +|`webp_support`|`boolean`|`true`|If set to `false`, the `type` attribute is omitted from `` elements| |`presets`|`object`| | | ## Art directed images