Skip to content

Commit

Permalink
Merge pull request #17 from BKWLD/fix-sanity-visual-videos
Browse files Browse the repository at this point in the history
Fix Sanity video support
  • Loading branch information
weotch authored Aug 7, 2023
2 parents e24e015 + e48a7e6 commit 10d4274
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ insert_final_newline = true
trim_trailing_whitespace = false
indent_style = space

[*.js]
indent_style = space

[*.php]
indent_style = space
indent_size = 4
Expand Down
9 changes: 8 additions & 1 deletion adapters/globals/sanity-visual.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default {

// Pass along props that were extrapolated from Sanity objects
image: getAssetRef(props.image),
video: getAssetRef(props.video),
video: getVideoUrl(props.video),
aspect: props.aspect ||
props.image?.asset?.metadata?.dimensions?.aspectRatio,
alt: props.alt || props.image?.alt,
Expand All @@ -49,6 +49,13 @@ function getAssetRef(source) {
return source?.asset?._id || source?.asset?._ref
}

// Get the video URL assuming it's been derefernced. I didn't build support
// for ref support here but it should be technically possible
function getVideoUrl(source) {
const dereferencedUrl = source?.asset?.url
if (dereferencedUrl) return dereferencedUrl
}

// Make object-position values from the hotspot data
export function makeObjectPosition(source) {
if (!source?.hotspot) return
Expand Down

0 comments on commit 10d4274

Please sign in to comment.