Last active
September 2, 2023 05:47
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
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
Related to this article: How to add ‘VideoObject’ Schema structured data to Cloudflare Stream videos in WordPress