1
1
<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
+
3
8
const { url } = useCldImageUrl ({ options: { src: ' /cld-sample-5.jpg' } })
4
9
console .log (url )
5
10
@@ -8,38 +13,84 @@ const { url: videoUrl } = useCldVideoUrl({
8
13
})
9
14
console .log (videoUrl )
10
15
11
- const mediaAssets = [
16
+ const mediaAssets: { tag : string , mediaType ? : MediaType }[] = [
12
17
{ tag: ' electric_car_product_gallery_demo' }, // by default mediaType: "image"
13
18
{ tag: ' electric_car_product_gallery_demo' , mediaType: ' video' },
14
19
{ tag: ' electric_car_360_product_gallery_demo' , mediaType: ' spin' },
15
20
]
16
21
17
22
const 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
+ }
18
48
</script >
19
49
20
50
<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"
24
67
width =" 987"
25
68
height =" 987"
26
- alt =" Sample Product "
69
+ alt =" twitter-title "
27
70
/>
28
71
<CldVideoPlayer
72
+ ref =" cldVideoRef"
73
+ auto-play
74
+ autoplay-mode =" on-scroll"
75
+ loop
76
+ muted
77
+ playsinline
29
78
width =" 1620"
30
79
height =" 1080"
31
- src =" videos/mountain-stars"
80
+ src =" videos/dog-running-snow"
81
+ :config =" { url: { cname: 'test' } }"
32
82
picture-in-picture-toggle
83
+ chapters-button
84
+ :chapters =" chapters"
85
+ :colors =" colors"
86
+ :transformation =" { raw_transformation: 'e_fade:2000,e_fade:-2000' }"
33
87
/>
34
- <!-- Usage of `CldUploadWidget.vue` component -->
35
88
<CldUploadWidget
36
89
v-slot =" { open }"
37
90
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"
43
94
>
44
95
<button
45
96
type =" button"
@@ -48,23 +99,41 @@ const buttonId = 'open-btn'
48
99
Upload an Image
49
100
</button >
50
101
</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
+ >
53
107
Upload
54
108
</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
+ }"
62
125
/>
63
126
<CldImage
64
127
src =" cld-sample-5"
65
128
width =" 987"
66
129
height =" 987"
67
130
alt =" Sample Product"
131
+ :crop =" {
132
+ type: 'thumb',
133
+ width: 600,
134
+ height: 600,
135
+ source: true,
136
+ }"
68
137
:overlays =" [
69
138
{
70
139
position: {
@@ -102,18 +171,4 @@ const buttonId = 'open-btn'
102
171
},
103
172
]"
104
173
/>
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
- />
119
174
</template >
0 commit comments