function display_slide($slide, $w, $h)
 {
     global $is_responsive;
     $before = '';
     $after = '';
     $img = '';
     // output the content based on the format selected
     switch ($slide['format']) {
         case 'image':
             if ($slide['link']) {
                 $target = $slide['target_blank'] ? 'target="_blank"' : '';
                 $before = '<a href="' . $slide['link'] . '" ' . $target . '>';
                 $after = '</a>';
             }
             // we're resizing images now (mostly because of HiDPI/retina support)
             $img = vt_resize('', $slide['media'], $w, $h, 1);
             // $img = '<img src="'. $slide['media'] .'" />'; // OLD
             // final image tag
             $img = '<img src="' . $img['url'] . '" width="' . $w . '" height="' . $h . '" alt="">';
             echo '<div class="slide imageSlide">' . $before . $img . $after . '</div>';
             // nesting image inside DIV to help with PNG transparency issues in IE
             //echo $before .'<img src="'. $slide['media'] .'" width="'. $w .'" height="'. $h .'" />'. $after;
             break;
         case 'video':
             $video = video_info($slide['media']);
             // valid YouTube or Vimeo
             if ($video) {
                 switch ($video['video_type']) {
                     case 'youtube':
                         $url = 'http://www.youtube.com/v/' . $video['video_id'];
                         $embedMethod = 'youtube-iframe';
                         break;
                     case 'vimeo':
                         $url = 'http://player.vimeo.com/video/' . $video['video_id'];
                         $embedMethod = 'vimeo-iframe';
                         break;
                     default:
                         // nothing here yet.
                 }
                 echo '<div class="slide videoSlide">';
                 embed_video($url, $w, $h, '', $embedMethod);
                 echo '</div>';
             } else {
                 _e('Please enter a valid Youtube or Vimeo Url', THEME_NAME);
             }
             break;
         case 'content':
             $ratio = $is_responsive ? 'data-ratio="' . round($w / $h, 3) . '"' : '';
             $before = '<div class="slide contentSlide" style="width: ' . $w . 'px; height: ' . $h . 'px;" ' . $ratio . '><div class="inner ugc">';
             $after = '</div></div>';
             echo $before . prep_content($slide['content'], 1, 1) . $after;
             break;
         case 'background-image':
             $ratio = $is_responsive ? 'data-ratio="' . round($w / $h, 3) . '"' : '';
             if ($slide['media']) {
                 $bg = 'transparent url(' . $slide['media'] . ') no-repeat 50% 50%';
                 $before = '<div class="slide contentSlide" style="background: ' . $bg . '; width: ' . $w . 'px; height: ' . $h . 'px;" ' . $ratio . '><div class="inner ugc">';
                 $after = '</div></div>';
             }
             echo $before . prep_content($slide['content'], 1, 1) . $after;
             break;
         case 'framed-image':
             $before = '<div style="width: ' . $w . 'px; height: ' . $h . 'px;" class="framedMedia">';
             $after = '</div>';
             // setup image
             if ($slide['media']) {
                 // we're resizing images now (mostly because of HiDPI/retina support)
                 $img = vt_resize('', $slide['media'], $w, $h, 1);
                 // $img = '<img src="'. $slide['media'] .'" />'; // OLD
                 // final image tag
                 $img = '<img src="' . $img['url'] . '" width="' . $w . '" height="' . $h . '" >';
                 if ($slide['link']) {
                     $target = $slide['target_blank'] ? 'target="_blank"' : '';
                     $img = '<a href="' . $slide['link'] . '" ' . $target . '>' . $img . '</a>';
                 }
                 $img = '<div class="slide framedImage">' . $img . '</div>';
             }
             // setup content
             $content = prep_content($slide['content'], 1, 1);
             $content = '<div class="framedContent ugc">' . $content . '</div>';
             // position image (left/right)
             $output = $img . $content;
             // default - image left
             if ($slide['position'] == 'right') {
                 $output = $content . $img;
             }
             // output slide
             echo $before . $output . $after;
             break;
         case 'framed-video':
             $before = '<div style="width: ' . $w . 'px; height: ' . $h . 'px;" class="slide framedMedia">';
             $after = '</div>';
             // setup image
             if ($slide['media']) {
                 $video = video_info($slide['media']);
                 // valid YouTube or Vimeo
                 if ($video) {
                     switch ($video['video_type']) {
                         case 'youtube':
                             $url = 'http://www.youtube.com/v/' . $video['video_id'];
                             $embedMethod = 'youtube-iframe';
                             break;
                         case 'vimeo':
                             $url = 'http://player.vimeo.com/video/' . $video['video_id'];
                             $embedMethod = 'vimeo-iframe';
                             break;
                         default:
                             // nothing here yet.
                     }
                 } else {
                     _e('Please enter a valid Youtube or Vimeo Url', THEME_NAME);
                 }
             }
             // setup content
             $content = prep_content($slide['content'], 1, 1);
             $content = '<div class="framedContent ugc">' . $content . '</div>';
             // output slide
             echo $before;
             if ($slide['position'] == 'right') {
                 echo $content;
             }
             echo '<div class="framedVideo">';
             embed_video($url, '612', '374', '', $embedMethod);
             echo '</div>';
             if ($slide['position'] !== 'right') {
                 echo $content;
             }
             echo $after;
             break;
     }
 }
Example #2
0
function post_meta_update($postId, $postmeta)
{
    foreach ($postmeta as $metabox) {
        $var = "obox_" . $metabox["name"];
        if (isset($_POST[$var])) {
            if ($metabox["input_type"] == "image" || $metabox["input_type"] == "background" || $metabox["input_type"] == "selfhosted") {
                $use_file_field = $var . "_file";
                // Upload files
                if (isset($_FILES[$use_file_field]["name"]) && $_FILES[$use_file_field]["name"] != "") {
                    $id = media_handle_upload($use_file_field, $postId);
                    if ($metabox["name"] == "other_media") {
                        set_post_thumbnail($postId, $id);
                    }
                    $attachment = wp_get_attachment_url($id);
                    //Update Post Meta
                    add_post_meta($postId, $metabox["name"], $attachment, true) or update_post_meta($postId, $metabox["name"], $attachment);
                } else {
                    //Update Post Meta
                    add_post_meta($postId, $metabox["name"], $_POST[$var], true) or update_post_meta($postId, $metabox["name"], $_POST[$var]);
                }
                // Custom Background
                if ($metabox["input_type"] == "background") {
                    add_post_meta($postId, $metabox["name"] . "_attributes", $_POST[$var . "_attributes"], true) or update_post_meta($postId, $metabox["name"] . "_attributes", $_POST[$var . "_attributes"]);
                }
                // Self Hosted Videos
                if ($metabox["input_type"] == "selfhosted") {
                    add_post_meta($postId, $metabox["name"] . "_mp4", $_POST[$var . "_mp4"], true) or update_post_meta($postId, $metabox["name"] . "_mp4", $_POST[$var . "_mp4"]);
                    add_post_meta($postId, $metabox["name"] . "_ogv", $_POST[$var . "_ogv"], true) or update_post_meta($postId, $metabox["name"] . "_ogv", $_POST[$var . "_ogv"]);
                }
            } else {
                add_post_meta($postId, $metabox["name"], $_POST[$var], true) or update_post_meta($postId, $metabox["name"], $_POST[$var]);
                // If this is the oEmbed field, let's look for the thumbnail related to the video
                if ($metabox["name"] == "video_link") {
                    if (strpos($_POST[$var], 'vimeo') || strpos($_POST[$var], 'yout')) {
                        $video_info = video_info($_POST[$var]);
                        try {
                            if (is_array($video_info) && isset($video_info['thumb_large'])) {
                                add_post_meta($postId, "oembed_info", $video_info, true) or update_post_meta($postId, "oembed_info", $video_info);
                            }
                        } catch (Exception $e) {
                        }
                    }
                }
            }
        }
    }
}
    $videoinf->duration = $channel->items[0]->contentDetails->duration;
    $videoinf->title = $channel->items[0]->snippet->title;
    $videoinf->description = $channel->items[0]->snippet->description;
    $videoinf->likes = $channel->items[0]->statistics->likeCount;
    $videoinf->dislikes = $channel->items[0]->statistics->dislikeCount;
    $videoinf->commentCount = $channel->items[0]->statistics->commentCount;
    $videoinf->favoriteCount = $channel->items[0]->statistics->favoriteCount;
    $videoinf->publishedAt = $channel->items[0]->snippet->publishedAt;
    echo "<h1>" . "After video id: " . $id . " gathered next info:\n" . "</h1>";
    echo "Picture of the video(default):" . '<img src="' . $channel->items[0]->snippet->thumbnails->medium->url . '">' . "\n";
    echo "<h1>" . "channel Title:" . $channel->items[0]->snippet->channelTitle . "\n" . "</h1>";
    echo "<h1>" . "title of the video:" . $channel->items[0]->snippet->title . "\n" . "</h1>";
    print '<object width="425" height="350" data="http://www.youtube.com/v/' . $id . '" type="application/x-shockwave-flash"><param name="src" value="http://www.youtube.com/v/" /></object>';
    echo "<h1>" . "\n" . "video URL:" . "</h1>" . "https://www.youtube.com/watch?v=" . $channel->items[0]->id . "\n";
    //echo "Comments".$comments."\n";
    echo "<h1>" . "duration:" . "</h1>" . $channel->items[0]->contentDetails->duration . "\n";
    echo "<h1>" . "description:" . "</h1>" . $channel->items[0]->snippet->description . "\n";
    echo "<h1>" . "Число лайков: " . "</h1>" . $channel->items[0]->statistics->likeCount . ".\n";
    echo "<h1>" . "like Count: " . "</h1>" . $channel->items[0]->statistics->dislikeCount . ".\n";
    echo "<h1>" . "comment Count: " . "</h1>" . $channel->items[0]->statistics->commentCount . ".\n";
    echo "<h1>" . "favorite Count " . "</h1>" . $channel->items[0]->statistics->favoriteCount . "\n" . "</h1>";
    echo "<h1>" . "published At " . "</h1>" . $channel->items[0]->snippet->publishedAt . "\n";
    echo "<h1>" . "------------------\n<br>" . "</h1>";
    return $videoinf;
}
video_info($id1);
video_info($id2);
video_info($id3);
video_info($id4);
video_info($id5);