@cliff-studio/sanity-plugin-bunny-input 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cliff-studio/sanity-plugin-bunny-input",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Sanity Studio plugin for uploading videos to Bunny Stream",
5
5
  "license": "MIT",
6
6
  "author": "Cliff Studio",
@@ -36,13 +36,20 @@ export function BunnyInput(props) {
36
36
  pollIntervalRef.current = null
37
37
  }
38
38
 
39
+ const width = Number(videoData.width)
40
+ const height = Number(videoData.height)
41
+
42
+ const hasDims = Number.isFinite(width) && Number.isFinite(height) && width > 0 && height > 0
43
+ const ratio = hasDims ? Number((width / height).toFixed(6)) : null
44
+
39
45
  onChange(
40
46
  set({
41
47
  ...value,
42
48
  status,
43
49
  duration: videoData.length,
44
- height: videoData.height ?? null,
45
- width: videoData.width ?? null,
50
+ height: hasDims ? height : null,
51
+ width: hasDims ? width : null,
52
+ ratio: ratio,
46
53
  thumbnailUrl: getThumbnailUrl(config.cdnHostname, value.videoId),
47
54
  playbackUrl: getPlaybackUrl(config.cdnHostname, value.videoId),
48
55
  mp4Url: getMp4Url(config.cdnHostname, value.videoId),
package/src/schema.js CHANGED
@@ -63,6 +63,12 @@ export const createBunnyVideoSchema = (config) => {
63
63
  name: 'height',
64
64
  readOnly: true,
65
65
  }),
66
+ defineField({
67
+ type: 'number',
68
+ title: 'Video ratio',
69
+ name: 'ratio',
70
+ readOnly: true,
71
+ }),
66
72
  defineField({
67
73
  type: 'string',
68
74
  title: 'Thumbnail URL',