Skip to content

Commit

Permalink
Prep for patch
Browse files Browse the repository at this point in the history
  • Loading branch information
zerodevx committed Aug 25, 2024
1 parent ba403fb commit a04edd6
Show file tree
Hide file tree
Showing 3 changed files with 2,644 additions and 1,396 deletions.
29 changes: 13 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ declare module '$lib/assets/*' {
### Under the hood

Local image transformations are delegated to the excellent
[vite-imagetools](https://github.com/JonasKruckenberg/imagetools) with a custom `run` directive.
This preset generates optimized images with sensible defaults, including a `base64` low-quality
[`vite-imagetools`](https://github.com/JonasKruckenberg/imagetools) with a custom `run` directive.
This preset generates optimised images with sensible defaults, including a `base64` low-quality
image placeholder.

Invoke the preset with the `?as=run` query param:
Expand Down Expand Up @@ -238,7 +238,7 @@ Renders into:

The full [repertoire](https://github.com/JonasKruckenberg/imagetools/blob/main/docs/directives.md)
of transformation directives offered by
[vite-imagetools](https://github.com/JonasKruckenberg/imagetools) can be used.
[`vite-imagetools`](https://github.com/JonasKruckenberg/imagetools) can be used.

<!-- prettier-ignore -->
```html
Expand All @@ -263,8 +263,11 @@ select when those conditions are true. Read up more on
import Img from '@zerodevx/svelte-img'
</script>

<!-- When the viewport is <=600px, tell the browser's image preloader that once the CSS for our
design has been parsed and applied, we expect the width of the image in our design to be 480px -->
<!--
When the viewport is <=600px, tell the browser's image preloader that once
the CSS for our design has been parsed and applied, we expect the width of
the image in our design to be 480px.
-->
<img {src} alt="cat" sizes="(max-width: 600px) 480px, 800px" />
```

Expand Down Expand Up @@ -317,7 +320,7 @@ attribute on the rendered `<img>` tag by default. This is supported by

### Batch loading local images

Use Vite's `import.meta.glob` [feature](https://vitejs.dev/guide/features.html#glob-import).
Use `Vite`'s `import.meta.glob` [feature](https://vitejs.dev/guide/features.html#glob-import).

<!-- prettier-ignore -->
```html
Expand Down Expand Up @@ -347,18 +350,12 @@ Use the `svelte-img` component on its own by passing a `src` object, like so:
import Img from '@zerodevx/svelte-img'
const src = {
img: { src: 'path/to/img', w: 1920, h: 1080 },
sources: {
// Order is important; last format is fallback img
webp: [
{ src: 'path/to/img', w: 1920 },
{ src: 'path/to/img', w: 1024 }
],
jpeg: [
{ src: 'path/to/img', w: 1920 },
{ src: 'path/to/img', w: 1024 }
]
}
webp: 'path/to/480.webp 480w, ...', //srcset
jpeg: '...'
},
img: { src: 'path/to/img', w: 1920, h: 1080 },
}
</script>

Expand Down
Loading

0 comments on commit a04edd6

Please sign in to comment.