-
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
38b3604
commit ad6c1ae
Showing
8 changed files
with
88 additions
and
3 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
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,32 @@ | ||
--- | ||
title: Unsplash Provider | ||
description: 'Nuxt Image has first class integration with Unsplash' | ||
navigation: | ||
title: Unsplash | ||
--- | ||
|
||
Integration between [Unsplash](https://unsplash.com/documentation#dynamically-resizable-images) and the image module. See [Unsplash License](Unsplash photos are made to be used freely.) for what usage is permitted. | ||
|
||
## Dynamically resizable images | ||
|
||
Every image returned by the Unsplash API is a dynamic image URL, which means that it can be manipulated to create new transformations of the image by simply adjusting the query parameters of the image URL. | ||
|
||
This enables resizing, cropping, compression, and changing the format of the image in realtime client-side, without any API calls. | ||
|
||
Under the hood, Unsplash uses [Imgix](/providers/imgix), a powerful image manipulation service to provide dynamic image URLs. | ||
|
||
## Supported parameters | ||
|
||
Unsplash officially support the parameters: | ||
|
||
`w, h`: for adjusting the width and height of a photo | ||
`crop`: for applying cropping to the photo | ||
`fm`: for converting image format | ||
`auto=format`: for automatically choosing the optimal image format depending on user browser | ||
`q`: for changing the compression quality when using lossy file formats | ||
`fit`: for changing the fit of the image within the specified dimensions | ||
`dpr`: for adjusting the device pixel ratio of the image | ||
The other parameters offered by Imgix can be used, but we don’t officially support them and may remove support for them at any time in the future. | ||
|
||
>💫 Tip | ||
>The API returns image URLs containing an ixid parameter. All resizing and manipulations of image URLs must keep this parameter as it allows for your application to report photo views and be compliant with the API Guidelines. |
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ const BuiltInProviders = [ | |
'static', | ||
'twicpics', | ||
'storyblok', | ||
'unsplash', | ||
'vercel' | ||
] | ||
|
||
|
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,14 @@ | ||
// https://unsplash.com/documentation#dynamically-resizable-images | ||
|
||
import { joinURL, withBase } from 'ufo' | ||
import type { ProviderGetImage } from 'src' | ||
import { operationsGenerator } from './imgix' | ||
|
||
const unsplashCDN = 'https://images.unsplash.com/' | ||
|
||
export const getImage: ProviderGetImage = (src, { modifiers = {}, baseURL = unsplashCDN } = {}) => { | ||
const operations = operationsGenerator(modifiers) | ||
return { | ||
url: withBase(joinURL(src + (operations ? ('?' + operations) : '')), baseURL) | ||
} | ||
} |
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