Composables

UseCldImageUrl

This composable is using @cloudinary-util/url-loader under the hood to generate the Cloudinary URL with certain optimizations.

Usage

The composable allows you to pass optimization options and the src of the image and in return get a full cloudinary url with the optimized images. Then, you can use this url any way you like (for example in the custom image component).

<script lang="ts" setup>
const { url } = useCldImageUrl({
  options: {
    src: "/cld-sample-5.jpg",
    tint: "40:253f8c",
    underlay: "/cld-sample-4.jpg",
    overlays: [
      {
        position: {
          gravity: "north",
          y: 60,
        },
        text: {
          color: "rgb:52a4ff80",
          fontFamily: "Source Sans Pro",
          fontSize: 320,
          fontWeight: "black",
          text: "MUSIC",
          letterSpacing: -10,
          lineSpacing: -100,
          stroke: true,
          border: "20px_solid_rgb:2d0eff99",
        },
      },
    ],
  },
});
</script>

Configuration

Apart from the image options, useCldImageUrl composable accepts two additional parameters; config and analytics.

General Options

Option NameTypeDefaultExample
cropstring"limit""thumb"
deliveryTypestring"upload""fetch"
effectsarray-[{ background: 'blue' }]
formatstring"auto""webp"
gravitystring"auto""faces"
heightnumber/string-600
overlaysarray-See Below
preserveTransformationsstringfalsetrue
qualitystring"auto""90"
rawTransformationsarray-['e_blur:2000']
removeBackgroundbool/stringfalsetrue
sanitizebooltrue if svgtrue (Applies only to SVG)
seoSuffixstring-my-image-content
srcstring-"my-public-id"
textstring-"Nuxt Cloudinary"
transformationsstring/array-['my-named-transformation']
underlaystring-"my-public-id"
underlaysarray-See Below
versionnumber-1234
widthnumber/string-600
zoomstring-0.5
zoompanbool/string/object-See Below

Effect Options

All effect props are disabled by default.

Option NameTypeExample
artstring"al_dente"
autoBrightnessbool/stringtrue, "80"
autoColorbool/stringtrue, "80"
autoContrastbool/stringtrue, "80"
assistColorblindbool/stringtrue, "20", "xray"
backgroundstring"blue"
blackwhitebool/stringtrue, "40"
blurbool/stringtrue, "800"
blurFacesbool/stringtrue, "800"
blurRegionbool/stringtrue, "1000,h_425,w_550,x_600,y_400"
borderstring"5px_solid_purple"
brightnessbool/stringtrue, "100"
brightnessHSBbool/stringtrue, "100"
cartoonifybool/stringtrue, "70:80"
colorstring"blue"
colorizestring"35,co_darkviolet"
contrastbool/stringtrue, "100", "level_-70"
distortstring"150:340:1500:10:1500:1550:50:1000", "arc:180.0"
fillLightbool/stringtrue, "70:20"
gammabool/stringtrue, "100"
gradientFadebool/stringtrue, "symmetric:10,x_0.2,y_0.4"
grayscalebooltrue
improvebool/stringtrue, "50", "indoor"
multiplybooltrue
negatebooltrue
oilPaintbool/stringtrue, "40"
opacitynumber/string40, "40"
outlinebool/stringtrue, "40", "outer:15:200"
overlaybooltrue
pixelatebool/stringtrue, "20"
pixelateFacesbool/stringtrue, "20"
pixelateRegionbool/stringtrue, "35,h_425,w_550,x_600,y_400"
redeyebool/stringtrue
replaceColorstring"saddlebrown", "2F4F4F:20", "silver:55:89b8ed"
saturationbool/stringtrue, "70"
screenbooltrue
sepiabool/stringtrue, "50"
shadowbool/stringtrue, "50,x_-15,y_15"
sharpenbool/stringtrue, "100"
shearstring"20.0:0.0"
simulateColorblindbool/string"deuteranopia"
tintbool/stringtrue, "100:red:blue:yellow"
unsharpMaskbool/stringtrue, "500"
vectorizebool/stringtrue, "3:0.5"
vibrancebool/stringtrue, "70"
vignettebool/stringtrue, "30"

View the Cloudinary docs to see learn more about using effects.

Overlay Options

The overlays prop is an array of objects with the following configuration options:

Property NameTypeExample
appliedEffectsarraySame as effects, added as applied transformation
effectsarraySee Below
positionobjectSee Below
publicIdstring"thumb"
textobjectstring
urlstring"https://.../image.jpg"

The position property can include:

Property NameTypeExample
anglenumber45
gravitystring'"north_west"'
xnumber10
ynumber10

Objects in the effects array can include everything in the effects options above as well as:

Property NameTypeExample
aspectRatiostring"3.0"
cropstring10
gravitystring'"north_west"'
heightnumber'600'
widthnumber'600'

The text property can include:

Property NameTypeExample
borderstring"20px_solid_blue"
colorstring"blueviolet"
fontFamilystring"Open Sans"
fontSizenumber48
fontWeightstring"bold"
letterSpacingnumber"14"
lineSpacingnumber"14"
strokebooltrue in coordination with Border
textDecorationstring"underline"