Created
December 16, 2016 02:10
-
-
Save AdamSoucie/d9f0c628b8b5d905dcc6c46c64cc3e95 to your computer and use it in GitHub Desktop.
This snippet takes a Dropbox linked video file and makes it work in WordPress
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
$dropbox_link = esc_attr( get_post_meta( get_the_ID(), 'name_dropbox_link', true ) ); | |
$image = get_the_post_thumbnail( get_the_ID() ); | |
if( $dropbox_link ) | |
{ | |
// Format the link properly | |
$formatted = str_replace( "?dl=0", "?dl=1", $dropbox_link ); | |
// Use site logo if there is no featured image | |
if( empty( $image ) ) | |
{ | |
$image = get_header_image(); | |
} | |
echo '<div class="dropbox video-embed-container">'; | |
echo '<video src="' . $formatted . '" controls preload="metadata" poster="'. $image .'">'; | |
echo '</div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment