Skip to content

Commit 597e66e

Browse files
authored
Merge pull request #48 from cloudinary/#39-enhance-cldvideo-cldposter
fix #39
2 parents 8ac038d + 7f358c0 commit 597e66e

21 files changed

Lines changed: 592 additions & 1802 deletions

src/components/CldImage.vue

Whitespace-only changes.

src/components/CldImage/CldImage.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { getPlaceholderURL } from "../../helpers/getPlaceholderURL";
1818
import { size } from "../../mixins/size";
1919
import { lazy } from "../../mixins/lazy";
2020
import { withOptions } from "../../mixins/withOptions";
21+
import { generateUrl } from '../../helpers/URLGenerator';
2122
2223
/**
2324
* Deliver images and specify image transformations using the cld-image (CldImage) component,
@@ -149,9 +150,10 @@ export default {
149150
150151
const htmlAttrs = getHTMLAttributes(this.options);
151152
152-
const src = Cloudinary.new(this.configuration).url(
153-
this.publicId,
154-
{
153+
const src = generateUrl({
154+
publicId: this.publicId,
155+
configuration: this.configuration,
156+
transformation: {
155157
...this.options,
156158
transformation: [
157159
...this.transformOptions.transformation,
@@ -163,15 +165,14 @@ export default {
163165
...(this.progressive ? [{ flags: ["progressive"] }] : [])
164166
]
165167
}
166-
);
168+
});
167169
168170
return {
169171
...this.nonCldAttrs,
170172
...htmlAttrs,
171173
src
172174
};
173175
},
174-
175176
shouldMeasureSize() {
176177
return !this.responsive;
177178
}

src/components/CldPoster.vue

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/components/CldTransformation/CldTransformation.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
},
1313
created() {
1414
if (this.registerTransformation) {
15-
this.registerTransformation(this.$attrs);
15+
this.registerTransformation(this.$attrs || {});
1616
}
1717
},
1818
render() {
File renamed without changes.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<script>
2+
import { normalizeTransformation, normalizeConfiguration } from "../../helpers/attributes";
3+
4+
/**
5+
* The image to be shown while a video is downloading or until the user hits the play button.
6+
* This component must be added as a child of the [CldVideo](#cldvideo) component.
7+
*
8+
* If this component is not given then the poster image defaults to the middle frame of the source video in jpg format.
9+
*/
10+
export default {
11+
name: "CldPoster",
12+
inject: {
13+
registerPoster: {
14+
default: null
15+
}
16+
},
17+
provide() {
18+
return {
19+
registerTransformation: this.registerTransformation,
20+
}
21+
},
22+
data() {
23+
return {
24+
transformations: [],
25+
};
26+
},
27+
mounted() {
28+
if (this.registerPoster) {
29+
const posterAttrs = this.$attrs || {};
30+
const configuration = normalizeConfiguration(posterAttrs);
31+
const transformation = [ normalizeTransformation(posterAttrs), ...this.transformations];
32+
33+
this.registerPoster({
34+
configuration,
35+
publicId: posterAttrs.publicId,
36+
transformation
37+
})
38+
// this.registerPoster({...(this.$attrs || {}), transformation: this.transformations });
39+
}
40+
},
41+
methods: {
42+
registerTransformation(transformation) {
43+
this.transformations = [...this.transformations, normalizeTransformation(transformation)];
44+
},
45+
},
46+
render(h) {
47+
return h(
48+
"div", {},
49+
this.$slots.default
50+
);
51+
}
52+
};
53+
</script>

0 commit comments

Comments
 (0)