-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61bcb90
commit 8245c22
Showing
6 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
title: Strapi Provider | ||
description: 'Nuxt Image with Strapi integration' | ||
navigation: | ||
title: Strapi | ||
--- | ||
|
||
Integration between [Strapi](https://strapi.io) and the image module. | ||
|
||
No specific configuration is required. You just need to specify `strapi` in your configuration to make it the default: | ||
```js{}[nuxt.config.js] | ||
export default { | ||
image: { | ||
strapi: {} | ||
} | ||
} | ||
``` | ||
|
||
Override default options: | ||
```js{}[nuxt.config.js] | ||
export default { | ||
image: { | ||
strapi: { | ||
baseURL: 'http://localhost:1337/uploads/' | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Modifiers | ||
The `breakpoint` modifier is used to specify the size of the image. | ||
|
||
By default, when the image is uploaded and **Enable responsive friendly upload** Strapi setting is enabled in the settings panel the plugin will generate the following responsive image sizes: | ||
|
||
| Name | Largest Dimension | | ||
| ------- | ----------------- | | ||
| `small` | 500px | | ||
| `medium`| 750px | | ||
| `large` | 1000px | | ||
|
||
You can override the default breakpoints. See the [Upload configuration](https://strapi.io/documentation/developer-docs/latest/development/plugins/upload.html#configuration) in the Strapi documentation. | ||
|
||
If you don't set breakpoint modifier, the original image size will be used: | ||
|
||
```html | ||
<nuxt-img provider="strapi" src="..." /> | ||
``` | ||
|
||
Define breakpoint modifier: | ||
```html | ||
<nuxt-img provider="strapi" src="..." :modifiers="{ breakpoint: 'small' }" /> | ||
``` | ||
|
||
:::alert{type="info"} | ||
Only one breakpoint can be modified per image. | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ProviderGetImage } from 'src' | ||
import { withBase, withoutLeadingSlash } from 'ufo' | ||
|
||
// https://strapi.io/documentation/developer-docs/latest/development/plugins/upload.html#upload | ||
|
||
export const getImage: ProviderGetImage = (src, { modifiers, baseURL = 'http://localhost:1337/uploads' } = {}) => { | ||
const breakpoint = modifiers?.breakpoint ?? '' | ||
|
||
if (!breakpoint) { | ||
return { | ||
url: withBase(src, baseURL) | ||
} | ||
} | ||
|
||
return { | ||
url: withBase(`${breakpoint}_${withoutLeadingSlash(src)}`, baseURL) | ||
} | ||
} | ||
|
||
export const validateDomains = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters