Skip to content

Commit 8a0ce7d

Browse files
committed
docs: rename $img page to use-image and update examples
1 parent e572c3c commit 8a0ce7d

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,34 @@
22
aside: false
33
---
44

5-
# $img utility
5+
# `useImage` composable
66

7-
Sometimes it's required to directly use a generated image URL with applied transformations instead of `<nuxt-img>` and `<nuxt-picture>` components. This is where `$img` comes in.
7+
Sometimes you might need to use a generated image URL directly with applied transformations instead of the `<nuxt-img>` and `<nuxt-picture>` components. This is where `useImage()` comes in (and the helper function it returns, which you will often see referenced directly as `$img` or `img`).
88

99
## Usage
1010

1111
```js
12-
const $img = useImage()
12+
const img = useImage()
1313

14-
$img(src, modifiers, options)
14+
img(src, modifiers, options)
1515
```
1616

1717
**Example:** Generate image URL for `backgroundImage` style.
1818

1919
```js
20-
const $img = useImage()
20+
const img = useImage()
2121
const backgroundStyles = computed(() => {
22-
const imgUrl = $img('https://github.com/nuxt.png', { width: 100 })
22+
const imgUrl = img('https://github.com/nuxt.png', { width: 100 })
2323
return { backgroundImage: `url('${imgUrl}')` }
2424
})
2525
```
2626

27-
### `$img.getSizes`
27+
### `img.getSizes`
2828

2929
```js
30-
const $img = useImage()
30+
const img = useImage()
3131

32-
$img.getSizes(src, { sizes, modifiers });
32+
img.getSizes(src, { sizes, modifiers });
3333
```
3434

3535
::alert{type="warning"}
@@ -61,9 +61,9 @@ const props = defineProps({
6161
default: '/img/header-bg.jpg'
6262
}
6363
})
64-
const $img = useImage()
64+
const img = useImage()
6565
const _srcset = computed(() => {
66-
return $img.getSizes(props.src, {
66+
return img.getSizes(props.src, {
6767
sizes: 'xs:100vw sm:100vw md:100vw lg:100vw xl:100vw',
6868
modifiers: {
6969
format: 'webp',
@@ -76,8 +76,8 @@ const _srcset = computed(() => {
7676

7777
<template>
7878
<v-img
79-
:lazy-src="$img(src, { width: 10, quality: 70 })"
80-
:src="$img(src, { height, quality: 70 })"
79+
:lazy-src="img(src, { width: 10, quality: 70 })"
80+
:src="img(src, { height, quality: 70 })"
8181
:srcset="_srcset.srcset"
8282
:height="height"
8383
:sizes="_srcset.sizes"

docs/content/6.advanced/1.custom-provider.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function getImage(src, { modifiers, baseURL } = {}, { options, $img }) {
2929
- `modifiers`: List of image modifiers that are defined in the image component or as a preset.
3030
- `ctx`: (`ImageCTX`) Image module runtime context
3131
- `options`: (`CreateImageOptions`) Image module global runtime options
32-
- `$img`: The [$img helper](/api/$img)
32+
- `$img`: The [$img helper](/api/use-image)
3333

3434
**Note:** Values in `ctx` might change. Use it with caution.
3535

0 commit comments

Comments
 (0)