11<script lang="ts" setup>
2- // Usage of `useCldImageUrl` composable
2+ import type {
3+ CloudinaryUploadWidgetError ,
4+ CloudinaryUploadWidgetResults ,
5+ } from ' @cloudinary-util/types'
6+ import type { MediaType } from ' ../src/runtime/components/CldProductGallery.vue'
7+
38const { url } = useCldImageUrl ({ options: { src: ' /cld-sample-5.jpg' } })
49console .log (url )
510
@@ -8,38 +13,84 @@ const { url: videoUrl } = useCldVideoUrl({
813})
914console .log (videoUrl )
1015
11- const mediaAssets = [
16+ const mediaAssets: { tag : string , mediaType ? : MediaType }[] = [
1217 { tag: ' electric_car_product_gallery_demo' }, // by default mediaType: "image"
1318 { tag: ' electric_car_product_gallery_demo' , mediaType: ' video' },
1419 { tag: ' electric_car_360_product_gallery_demo' , mediaType: ' spin' },
1520]
1621
1722const buttonId = ' open-btn'
23+
24+ const cldVideoRef = ref ()
25+
26+ const chapters = {
27+ 0 : ' Chapter 1' ,
28+ 6 : ' Chapter 2' ,
29+ 9 : ' Chapter 3' ,
30+ }
31+
32+ const colors = {
33+ accent: ' #ff0000' ,
34+ base: ' #00ff00' ,
35+ text: ' #0000ff' ,
36+ }
37+
38+ const onResult = (results : CloudinaryUploadWidgetResults ) => {
39+ console .log (' results' , results )
40+ }
41+ const onError = (
42+ error : CloudinaryUploadWidgetError ,
43+ results : CloudinaryUploadWidgetResults ,
44+ ) => {
45+ console .log (' error' , error )
46+ console .log (' results' , results )
47+ }
1848 </script >
1949
2050<template >
21- <!-- Usage of `CldImage.vue` component -->
22- <CldImage
23- src="cld-sample-5"
51+ <button :id =" buttonId" >
52+ Select Image or Video
53+ </button >
54+ <CldMediaLibrary
55+ api-key="12345"
56+ :button-id =" buttonId "
57+ style =" height : 600px "
58+ />
59+ <CldProductGallery
60+ :media-assets =" mediaAssets "
61+ cloud-name="demo"
62+ :button-id =" buttonId "
63+ />
64+ <CldOgImage
65+ src="cld-sample-2"
66+ twitter-title="test"
2467 width="987"
2568 height="987"
26- alt="Sample Product "
69+ alt="twitter-title "
2770 />
2871 <CldVideoPlayer
72+ ref="cldVideoRef"
73+ auto-play
74+ autoplay-mode="on-scroll"
75+ loop
76+ muted
77+ playsinline
2978 width="1620"
3079 height="1080"
31- src="videos/mountain-stars"
80+ src="videos/dog-running-snow"
81+ :config =" { url: { cname: ' test' } } "
3282 picture-in-picture-toggle
83+ chapters-button
84+ :chapters =" chapters "
85+ :colors =" colors "
86+ :transformation =" { raw_transformation: ' e_fade:2000,e_fade:-2000' } "
3387 />
34- <!-- Usage of `CldUploadWidget.vue` component -->
3588 <CldUploadWidget
3689 v-slot =" { open } "
3790 upload-preset="nuxt-cloudinary-unsigned"
38- :on-upload ="
39- (result , w ) => {
40- console .log (result , w );
41- }
42- "
91+ :tags =" [' sad' , ' music' ] "
92+ :on-error =" onError "
93+ :on-result =" onResult "
4394 >
4495 <button
4596 type =" button"
@@ -48,23 +99,41 @@ const buttonId = 'open-btn'
4899 Upload an Image
49100 </button >
50101 </CldUploadWidget >
51- <!-- Usage of `CldUploadButton.vue` component -->
52- <CldUploadButton upload-preset="nuxt-cloudinary-unsigned">
102+ <CldUploadButton
103+ upload-preset="nuxt-cloudinary-unsigned"
104+ :on-error =" onError "
105+ :on-result =" onResult "
106+ >
53107 Upload
54108 </CldUploadButton >
55- <p >CldOgImage is here. Inspect the html meta to see the result</p >
56- <CldOgImage
57- src="cld-sample-2"
58- twitter-title="test"
59- width="300"
60- height="300"
61- alt="test"
109+ <CldImage
110+ src="cld-sample-5"
111+ width="987"
112+ height="987"
113+ alt="Sample Product"
114+ crop="fill"
115+ priority
116+ sizes="(max-width: 600px) 480px,
117+ 800px"
118+ :replace-background =" { prompt: ' fish tank' , seed: 3 } "
119+ :extract =" {
120+ prompt: ' space jellyfish' ,
121+ multiple: true ,
122+ mode: ' mask' ,
123+ invert: true ,
124+ } "
62125 />
63126 <CldImage
64127 src="cld-sample-5"
65128 width="987"
66129 height="987"
67130 alt="Sample Product"
131+ :crop =" {
132+ type: ' thumb' ,
133+ width: 600 ,
134+ height: 600 ,
135+ source: true ,
136+ } "
68137 :overlays =" [
69138 {
70139 position: {
@@ -102,18 +171,4 @@ const buttonId = 'open-btn'
102171 },
103172 ] "
104173 />
105-
106- <button :id =" buttonId" >
107- Select Image or Video
108- </button >
109- <CldMediaLibrary
110- api-key="12345"
111- :button-id =" buttonId "
112- style =" height : 600px "
113- />
114- <CldProductGallery
115- :media-assets =" mediaAssets "
116- cloud-name="demo"
117- :button-id =" buttonId "
118- />
119174</template >
0 commit comments