Skip to content

Commit

Permalink
Merge pull request #29 from BKWLD/passthrough-gifs
Browse files Browse the repository at this point in the history
Passthrough gifs
  • Loading branch information
weotch authored Nov 27, 2024
2 parents a4a2403 + 61b795b commit 39684f4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
20 changes: 20 additions & 0 deletions demo/content/demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ This uses an explicit `imgix` provider to produce a `srcset` using `@cloak-app/v
</cloak-visual>
```

Gifs are ignored, though:

<cloak-visual
image='/assets/example.gif'
provider='imgix'
sizes='100vw'
alt='ASCII Gif'
width='100%'>
</cloak-visual>

```vue
<cloak-visual
image='/assets/example.gif'
provider='imgix'
sizes='100vw'
alt='ASCII Gif'
width='100%'>
</cloak-visual>
```

## Responsive component

Conditionally render landscape or portrait visual instances using `imgix` to produce srcset crops.
Expand Down
Binary file added demo/static/assets/example.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion plugins/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export function img(url, modifiers, options = {}, {
// If no URL passed, abort
if (!url) return

// Passthrough gifs without trying to format/compress them
if (url.toLowerCase().endsWith(".gif")) return url;

// If domains were provided, try and get just the image path
if (domains) url = imgPath(domains, url)

Expand Down Expand Up @@ -78,7 +81,8 @@ export function srcset(url, sizes, modifiers, options, {
$cloakImg, maxWidth
} = {}) {
if (!url || !sizes) return
// Don't support srcset for GIF

// Don't generate srcset for GIF
if (url.toLowerCase().endsWith('.gif')) return

// Don't output src options that are greater then a 2X version of the max
Expand Down

0 comments on commit 39684f4

Please sign in to comment.