forked from nuxt/image
-
Notifications
You must be signed in to change notification settings - Fork 0
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
758ec42
commit e9a5542
Showing
8 changed files
with
105 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,20 @@ | ||
--- | ||
title: Glide Provider | ||
description: 'Nuxt Image has first class integration with Glide' | ||
navigation: | ||
title: glide | ||
--- | ||
|
||
Integration between [glide](https://glide.thephpleague.com/) and the image module. | ||
|
||
To use this provider you just need to specify the base url of your service in glide. | ||
|
||
```js{}[nuxt.config.js] | ||
export default { | ||
image: { | ||
glide: { | ||
baseURL: 'https://glide.example.com' | ||
} | ||
} | ||
} | ||
``` |
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,55 @@ | ||
// https://glide.thephpleague.com/2.0/api/quick-reference/ | ||
|
||
import { ProviderGetImage } from 'src' | ||
import { joinURL, encodeQueryItem, encodePath } from 'ufo' | ||
import { createOperationsGenerator } from '~image' | ||
|
||
const operationsGenerator = createOperationsGenerator({ | ||
keyMap: { | ||
orientation: 'or', | ||
flip: 'flip', | ||
crop: 'crop', | ||
width: 'w', | ||
height: 'h', | ||
fit: 'fit', | ||
dpr: 'dpr', | ||
bri: 'bri', | ||
con: 'con', | ||
gam: 'gam', | ||
sharp: 'sharp', | ||
blur: 'blur', | ||
pixel: 'pixel', | ||
filt: 'filt', | ||
mark: 'mark', | ||
markw: 'markw', | ||
markh: 'markh', | ||
markx: 'markx', | ||
marky: 'marky', | ||
markpad: 'markpad', | ||
markpos: 'markpos', | ||
markalpha: 'markalpha', | ||
background: 'bg', | ||
border: 'border', | ||
quality: 'q', | ||
format: 'fm' | ||
}, | ||
valueMap: { | ||
fit: { | ||
fill: 'fill', | ||
inside: 'max', | ||
outside: 'stretch', | ||
cover: 'crop', | ||
contain: 'contain' | ||
} | ||
}, | ||
joinWith: '&', | ||
formatter: (key, val) => encodeQueryItem(key, val) | ||
}) | ||
|
||
export const getImage: ProviderGetImage = (src, { modifiers = {}, baseURL = '/' } = {}) => { | ||
const params = operationsGenerator(modifiers) | ||
|
||
return { | ||
url: joinURL(baseURL, encodePath(src) + (params ? '?' + params : '')) | ||
} | ||
} |
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