Skip to content

Instantly share code, notes, and snippets.

@henshaw
Last active May 17, 2025 14:58
Show Gist options
  • Select an option

  • Save henshaw/7452ecb35fcd8fd916c911cd41c61ab3 to your computer and use it in GitHub Desktop.

Select an option

Save henshaw/7452ecb35fcd8fd916c911cd41c61ab3 to your computer and use it in GitHub Desktop.
VideoObject Schema structured data for Cloudflare Stream videos in WordPress. To be used with Genesis Custom Blocks plugin.
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "VideoObject",
"name": "<?php block_field( 'cs-name' ); ?>",
"description": "<?php block_field( 'cs-description' ); ?>",
"thumbnailUrl": "https://<?php block_field( 'cs-subdomain' ); ?>/<?php block_field( 'cs-id' ); ?>/thumbnails/thumbnail.jpg",
"uploadDate": "<?php the_time('c'); ?>",
"duration": "PT<?php $cshours = block_field( 'cs-hours', false ); if ( ! empty( $cshours ) ) { echo $cshours . 'H'; } ?><?php $csminutes = block_field( 'cs-minutes', false ); if ( ! empty( $csminutes ) ) { echo $csminutes . 'M'; } ?><?php $csseconds = block_field( 'cs-seconds', false ); if ( ! empty( $csseconds ) ) { echo $csseconds . 'S'; } ?>",
"embedUrl": "https://<?php block_field( 'cs-subdomain' ); ?>/<?php block_field( 'cs-id' ); ?>/iframe"
}
</script>
@henshaw
Copy link
Copy Markdown
Author

henshaw commented Feb 23, 2021

@henshaw
Copy link
Copy Markdown
Author

henshaw commented Mar 10, 2021

Updated code to require square and portrait images. If you've come this far, might as well go all the way!

@henshaw
Copy link
Copy Markdown
Author

henshaw commented May 17, 2025

Updated the code to link to the thumbnail automatically created by and served from Cloudflare Stream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment