Skip to content

Instantly share code, notes, and snippets.

@henshaw
Last active September 2, 2023 05:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henshaw/7452ecb35fcd8fd916c911cd41c61ab3 to your computer and use it in GitHub Desktop.
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": "<?php block_field( 'cs-thumbnail' ); ?>",
"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
Author

henshaw commented Feb 23, 2021

@henshaw
Copy link
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!

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