CMS Development

DOctober
Participant

How to extract the content URL from a Video File object.

SOLVE

Hi! I have a question about the Video field: https://developers.hubspot.com/docs/cms/building-blocks/module-theme-fields#video


You see I'm trying to set up a Schema data structure for our video posts, and one highly recommended property is the contentUrl or embedUrl. Is there any way to extract the content url from the Video File object?? Like this: https://5638311.fs1.hubspotusercontent-na1.net/hubfs/5638311/Videos/Demos/ACA%20Demo.mp4

1 Accepted solution
Stephanie-OG
Solution
Key Advisor

How to extract the content URL from a Video File object.

SOLVE

Hi @DOctober - as far as I can tell there's no way to extract the video file's URL from the Video field, probably because of the HubSpot Video functionalities. 

 

However, when I'm doing something custom with videos, I usually use the File field instead (it has a "Video" option), which outputs the video URL you can use for your schema.  

 


Stephanie O'Gay Garcia

Freelance HubSpot CMS Developer

Website | Contact

View solution in original post

4 Replies 4
JohnLaprairie
Participant | Gold Partner
Participant | Gold Partner

How to extract the content URL from a Video File object.

SOLVE

I was having this issue trying to set a background video in a custom Hero module on a dynamic page template.

In the database I set a video background column with the property of VIDEO.

This gives a file ID number but like above I could not get the File URL from this ID. After some investigating and paying attention to various IDs and File IDs I found that the database ID I was getting was +1 from the video file ID. So I thought this may be workable. My code below allowed me to access the File ID URL from the database ID. I have tested it on 3 different videos and so far it works. Now I just have to get the custom thumbnail for the poster!

{% if dynamic_page_hubdb_row && dynamic_page_hubdb_row.hero_background_choice['name'] == 'Video' %}
{% set videoID = dynamic_page_hubdb_row.hero_background_video %}
{% set videoID = videoID|int - 1 %}
{% set file = file_by_id( videoID ) %}
{% set backgroundOptions = '{"loop": {{ module.background.loop }}, "source":{"mp4":" {{ file.url }}" ...etc..hero video stuff...etc..
{% endif %}

 

0 Upvotes
SBussey
Participant

How to extract the content URL from a Video File object.

SOLVE

For those that see this, it's possible that it would be accurate, but that would just be a coincidence. It looks like the video player gets allocated an auto-sequenced ID after the file. These IDs are global, so if another file is uploaded at the same time then I think you'd lose the association.

 

Working through this myself now 🙂 

0 Upvotes
Stephanie-OG
Solution
Key Advisor

How to extract the content URL from a Video File object.

SOLVE

Hi @DOctober - as far as I can tell there's no way to extract the video file's URL from the Video field, probably because of the HubSpot Video functionalities. 

 

However, when I'm doing something custom with videos, I usually use the File field instead (it has a "Video" option), which outputs the video URL you can use for your schema.  

 


Stephanie O'Gay Garcia

Freelance HubSpot CMS Developer

Website | Contact

Jaycee_Lewis
Community Manager
Community Manager

How to extract the content URL from a Video File object.

SOLVE

Hi, @DOctober 👋 Thanks for reaching out.

Let's see what our community has to say. Hey @assi  and @Stephanie-OG do you have any insight here? 

 

Thank you! – Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot