-
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.
Co-authored-by: Aditya Patadia <[email protected]>
- Loading branch information
1 parent
a12d4fe
commit 8aaab14
Showing
8 changed files
with
163 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,49 @@ | ||
--- | ||
title: Gumlet Provider | ||
description: 'Nuxt Image has first class integration with Gumlet' | ||
navigation: | ||
title: Gumlet | ||
--- | ||
|
||
Integration between [Gumlet](https://docs.gumlet.com/) and the image module. | ||
|
||
To use this provider you just need to specify the base url of your service in Gumlet. | ||
|
||
```js{}[nuxt.config.js] | ||
export default { | ||
image: { | ||
gumlet: { | ||
baseURL: 'https://demo.gumlet.io' | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## gumlet `mode` values | ||
|
||
Gumlet supports all the [the standard values for `fit` property](/components/nuxt-img#fit) of Nuxt image and Nuxt picture. | ||
|
||
|
||
## gumlet modifiers | ||
|
||
Beside the [standard modifiers](/components/nuxt-img#modifiers), you can also pass all gumlet-specific render API parameters to the `modifiers` prop. | ||
|
||
For a full list of these modifiers and their uses, check out [Gumlet's image Rendering API documentation](https://docs.gumlet.com/reference/image-transform-size#mode). | ||
|
||
## gumlet best practices | ||
|
||
Some common best practices when using Gumlet, would be to include our `format=auto` parameter, which will automatically apply the best format for an image and compress the image as well. Combine this with some top of intelligent cropping and resizing and you will have a great image! | ||
|
||
```html | ||
<nuxt-img | ||
provider="gumlet" | ||
src="/sea.jpeg" | ||
width="300" | ||
height="500" | ||
fit="cover" | ||
:modifiers="{ format: 'auto', compress: 'true' }" | ||
/> | ||
``` | ||
|
||
This will return a 300 x 500 image, which has been compressed, will display next-gen formats for a browser, and has been cropped intelligently to the face of the [woman in the hat](https://demo.gumlet.io/sea.jpeg?format=auto&w=300&h=500&compress=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
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ const BuiltInProviders = [ | |
'fastly', | ||
'glide', | ||
'imagekit', | ||
'gumlet', | ||
'imgix', | ||
'ipx', | ||
'netlify', | ||
|
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,78 @@ | ||
import { joinURL } from 'ufo' | ||
import type { ProviderGetImage } from 'src' | ||
import { createOperationsGenerator } from '~image' | ||
|
||
export const operationsGenerator = createOperationsGenerator({ | ||
keyMap: { | ||
width: 'w', | ||
height: 'h', | ||
format: 'format', | ||
quality: 'q', | ||
backgroundColor: 'bg', | ||
rotate: 'rot', | ||
mask: 'mask', | ||
auto: 'auto', | ||
crop: 'crop', | ||
brightness: 'bri', | ||
contrast: 'con', | ||
exposure: 'exp', | ||
gamma: 'gam', | ||
highlight: 'high', | ||
hueShift: 'hue', | ||
invert: 'invert', | ||
saturation: 'sat', | ||
sharpen: 'sharp', | ||
padding: 'pad', | ||
paletteColorCount: 'colors', | ||
colorPaletteExtraction: 'palette', | ||
cssPrefix: 'prefix', | ||
jsonFaceData: 'faces', | ||
fillMode: 'fill', | ||
fillColor: 'fill-color', | ||
transparency: 'transparency', | ||
focalPointDebug: 'fp-debug', | ||
focalPointXPosition: 'fp-x', | ||
focalPointYPosition: 'fp-y', | ||
focalPointZoom: 'fp-z', | ||
chromaSubsampling: 'chromasub', | ||
colorQuantization: 'colorquant', | ||
colorSpace: 'colorspace', | ||
dotsPerInch: 'dpi', | ||
pdfPageNumber: 'page', | ||
pixelDensity: 'dpr', | ||
aspectRatio: 'ar', | ||
sourceRectangleRegion: 'rect', | ||
monochrome: 'monochrome' | ||
}, | ||
valueMap: { | ||
fit: { | ||
fill: 'scale', | ||
inside: 'max', | ||
outside: 'min', | ||
cover: 'crop', | ||
contain: 'fill', | ||
clamp: 'clamp', | ||
clip: 'clip', | ||
facearea: 'facearea', | ||
fillMax: 'fillmax' | ||
}, | ||
format: { | ||
gif: 'gif', | ||
jpg: 'jpg', | ||
json: 'json', | ||
png: 'png', | ||
avif: 'avif', | ||
webp: 'webp', | ||
auto: 'auto' | ||
} | ||
}, | ||
joinWith: '&', | ||
formatter: (key, value) => `${key}=${value}` | ||
}) | ||
|
||
export const getImage: ProviderGetImage = (src, { modifiers = {}, baseURL = '/' } = {}) => { | ||
const operations = operationsGenerator(modifiers) | ||
return { | ||
url: joinURL(baseURL, src + (operations ? ('?' + operations) : '')) | ||
} | ||
} |
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