I'm Adding a (Vine.co) Meta Box to WordPress Page/Post.
I found the guide which demonstrate how to add a custom meta box for (YouTube Videos) only.
http://www.iamclarence.com/blog/2012...epost-editing/
I'm changing this code to work with vine.co videos.
I just replace the YouTube output with Vine output and change the variable names to improve readability.
PHP Code:// original
preg_match('%(?:youtube\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $featuredVideoURL, $youTubeMatch);
if($youTubeMatch[1]){
// return youtube embed code
}else{
return null;
}
This is the output code which I'm using in my themePHP Code:// new
// (for readability, replace all instances of "youTubeMatch"
// with "vineMatch"; leave everything else the same
preg_match('/property="twitterlayer:stream" content="(.*?)"/', $featuredVideoURL, $vineMatch);
if($vineMatch[1]){
// return vine embed code
<iframe class="vine-embed" src="https://vine.co/v/'.$vineMatch[1].'embed/simple" width="600" height="600" frameborder="0"></iframe>
<script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>
}else{
return null;
}
I believe I am unable to implement the function correctly maybe there is something wrong in returning vine embed code.PHP Code:<?php $the_video_output = getFeaturedVideo($post->ID, 708, 366); echo $the_video_output; ?>
This is the Vine function which I want to replace with YouTube function
Another function I want to merge is to get the vine featured image and set it automatically in WordPress using the guide below?PHP Code:function vine($id) { // gets the raw .mp4 url from the vine id
$vine = file_get_contents("http://vine.co/v/{$id}");
preg_match('/property="twitterlayer:stream" content="(.*?)"/', $vine, $matches);
return ($matches[1]) ? $matches[1] : false;
}
https://halgatewood.com/php-get-vine...deo-thumbnail/
If anyone can help it will be greatly appreciated. Thanks in advance.



Reply With Quote

Bookmarks