示例#1
0
function substituteVideo($post_text, $w, $h)
{
    $tag = '<video>';
    $tag_end = '</video>';
    $pos_start = -1;
    while (($pos_start = themerex_strpos($post_text, themerex_substr($tag, 0, -1) . ' ', $pos_start + 1)) !== false) {
        $pos_end = themerex_strpos($post_text, themerex_substr($tag, -1), $pos_start);
        $pos_end2 = themerex_strpos($post_text, $tag_end, $pos_end);
        $tag_text = themerex_substr($post_text, $pos_start, ($pos_end2 !== false ? $pos_end2 + 7 : $pos_end) - $pos_start + 1);
        if (($src = getTagAttrib($tag_text, $tag, 'src')) == '') {
            $src = getTagAttrib($tag_text, $tag, 'url');
        }
        if ($src != '') {
            $auto = getTagAttrib($tag_text, $tag, 'autoplay');
            $src = getVideoPlayerURL($src, $auto != '' && is_single());
            $tag_w = getTagAttrib($tag_text, $tag, 'width');
            $tag_h = getTagAttrib($tag_text, $tag, 'height');
            $tag_a = getTagAttrib($tag_text, $tag, 'align');
            $tag_s = getTagAttrib($tag_text, $tag, 'style');
            $pos_end = $pos_end2 !== false ? $pos_end2 + 8 : $pos_end + 1;
            $post_text = themerex_substr($post_text, 0, themerex_substr($post_text, $pos_start - 3, 3) == '<p>' ? $pos_start - 3 : $pos_start) . '<iframe class="video_frame' . ($tag_a ? ' align' . $tag_a : '') . '"' . ' src="' . $src . '"' . ' width="' . ($tag_w ? $tag_w : $w) . '"' . ' height="' . ($tag_h ? $tag_h : $h) . '"' . ($tag_s ? ' style="' . $tag_s . '"' : '') . ' frameborder="0" webkitAllowFullScreen="webkitAllowFullScreen" mozallowfullscreen="mozallowfullscreen" allowFullScreen="allowFullScreen"></iframe>' . themerex_substr($post_text, themerex_substr($post_text, $pos_end, 4) == '</p>' ? $pos_end + 4 : $pos_end);
        }
    }
    return $post_text;
}
示例#2
0
function sc_video($atts, $content = null)
{
    if (in_shortcode_blogger()) {
        return '';
    }
    extract(shortcode_atts(array("id" => "", "class" => "", "url" => '', "src" => '', "image" => '', "title" => 'off', "ratio" => '16:9', "autoplay" => 'off', "width" => '100%', "height" => '295', "top" => "", "bottom" => "", "left" => "", "right" => ""), $atts));
    if ($src == '' && $url == '' && isset($atts[0])) {
        $src = $atts[0];
    }
    $ed = themerex_substr($width, -1);
    $s = getStyleString($top, $right, $bottom, $left, $width, $height != '' ? $height + (sc_param_is_on($title) ? 21 : 0) : '');
    $url = $src != '' ? $src : $url;
    if ($image != '' && sc_param_is_off($image)) {
        $image = '';
    } else {
        if (sc_param_is_on($autoplay) && is_single()) {
            $image = '';
        } else {
            if ($image > 0) {
                $attach = wp_get_attachment_image_src($image, 'full');
                if (isset($attach[0]) && $attach[0] != '') {
                    $image = $attach[0];
                }
            }
            $image = getResizedImageURL(empty($image) ? get_the_ID() : $image, $ed != '%' ? $width : null, $height);
            if (empty($image)) {
                $image = getVideoCoverImage($url);
            }
        }
    }
    $url = getVideoPlayerURL($src != '' ? $src : $url);
    $ratio = empty($ratio) ? "16:9" : str_replace(array('/', '\\', '-'), ':', $ratio);
    $video = '<video' . ($id ? ' id="' . $id . '"' : '') . ' class="sc_video' . (!empty($class) ? ' ' . $class : '') . '"' . ' src="' . $url . '"' . ' width="' . $width . '" height="' . $height . '"' . ' data-width="' . $width . '" data-height="' . $height . '"' . ' data-ratio="' . esc_attr($ratio) . '"' . ($image ? ' data-image="' . esc_attr($image) . '"' : '') . ' data-title="' . $title . '"' . ($s != '' ? ' style="' . $s . '"' : '') . ($image && get_theme_option('substitute_video') == 'yes' || sc_param_is_on($autoplay) && is_single() ? ' autoplay="autoplay"' : '') . ' controls="controls"' . '>' . '</video>';
    if (get_custom_option('substitute_video') == 'no') {
        $video = getVideoFrame($video, $image, sc_param_is_on($title), $s);
    }
    if (get_theme_option('use_mediaelement') == 'yes') {
        themerex_enqueue_script('wp-mediaelement');
    }
    return $video;
}
示例#3
0
 $recent['post_content_prepared'] = do_shortcode($recent['post_content']);
 $recent['post_descr'] = $recent['post_format'] == 'quote' ? $recent['post_content_prepared'] : (!empty($recent['post_excerpt']) ? $recent['post_excerpt'] : getShortString(strip_tags(strip_shortcodes($recent['post_content'])), 300));
 $recent['post_gallery'] = $recent['post_video'] = $recent['post_audio'] = '';
 if ($recent['post_format'] == 'gallery') {
     $recent['post_gallery'] = buildGalleryTag(getPostGallery($recent['post_content'], $recent['ID']), 310, 310);
 } else {
     if ($recent['post_format'] == 'video') {
         $recent['post_video'] = getPostVideo($recent['post_content_prepared'], false);
         if ($recent['post_video'] == '') {
             $src = getVideoPlayerURL(getPostVideo($recent['post_content_prepared'], true), $recent['post_thumb'] != '');
             if ($src) {
                 $recent['post_video'] = substituteVideo('<video src="' . $src . '">', 310, 310);
             }
         }
         if ($recent['post_video'] != '' && get_custom_option('substitute_video') == 'yes') {
             $src = getVideoPlayerURL(getPostVideo($recent['post_video']), $recent['post_thumb'] != '');
             if ($src) {
                 $recent['post_video'] = substituteVideo('<video src="' . $src . '">', 310, 310);
             }
         }
     } else {
         if ($recent['post_format'] == 'audio') {
             $recent['post_audio'] = getPostAudio($recent['post_content_prepared'], false);
             if ($recent['post_audio'] == '') {
                 $src = getPostAudio($recent['post_content_prepared'], true);
                 if ($src) {
                     $recent['post_audio'] = substituteAudio('<audio src="' . $src . '">');
                 }
             }
             if ($recent['post_audio'] != '' && get_custom_option('substitute_audio') == 'yes') {
                 $src = getPostAudio($recent['post_audio']);
function sc_video($atts, $content = null)
{
    if (in_shortcode_blogger()) {
        return '';
    }
    extract(shortcode_atts(array("id" => "", "url" => '', "src" => '', "image" => '', "title" => 'off', "autoplay" => 'off', "width" => '100%', "height" => '295', "top" => "", "bottom" => "", "left" => "", "right" => ""), $atts));
    if ($src == '' && $url == '' && isset($atts[0])) {
        $src = $atts[0];
    }
    if ($image > 0) {
        $attach = wp_get_attachment_image_src($image, 'full');
        if (isset($attach[0]) && $attach[0] != '') {
            $image = $attach[0];
        }
    }
    $s = ($top !== '' ? 'margin-top:' . $top . 'px;' : '') . ($bottom !== '' ? 'margin-bottom:' . $bottom . 'px;' : '') . ($left !== '' ? 'margin-left:' . $left . 'px;' : '') . ($right !== '' ? 'margin-right:' . $right . 'px;' : '') . ($width !== '' ? 'width:' . $width . 'px;' : '') . ($height !== '' ? 'height:' . $height . 'px;' : '');
    $url = getVideoPlayerURL($src != '' ? $src : $url);
    $output = '';
    $video = '<video' . ($id ? ' id="' . $id . '"' : '') . ' class="sc_video" src="' . $url . '" width="' . $width . '" height="' . $height . '"' . ($image || sc_param_is_on($autoplay) && is_single() ? ' autoplay="autoplay"' : '') . ($s != '' ? ' style="' . $s . '"' : '') . ' controls="controls"><source type="video/mp4" src="' . $url . '"></source></video>';
    if ($image) {
        $video = substituteVideo($video, $width, $height);
        $output = getVideoFrame($video, $image, sc_param_is_on($title), $s);
    } else {
        $output = $video;
    }
    return $output;
    /*
    	return '<iframe' . ($id ? ' id="' . $id . '"' : '') . ' class="sc_video" src="' . $url . '" width="' . $width . '" height="' . $height . '"'.($s!='' ? ' style="'.$s.'"' : '').' frameborder="0" webkitAllowFullScreen="webkitAllowFullScreen" mozallowfullscreen="mozallowfullscreen" allowFullScreen="allowFullScreen"></iframe>';
    */
}
示例#5
0
function sc_video($atts, $content = null)
{
    if (in_shortcode_blogger()) {
        return '';
    }
    extract(shortcode_atts(array("id" => "", "url" => "", "src" => "", "image" => "", "title" => "", "autoplay" => "off", "width" => "", "height" => "", "top" => "", "bottom" => "", "left" => "", "right" => ""), $atts));
    if ($src == '' && $url == '' && isset($atts[0])) {
        $src = $atts[0];
    }
    $s = ($top !== '' ? 'margin-top:' . $top . 'px;' : '') . ($bottom !== '' ? 'margin-bottom:' . $bottom . 'px;' : '') . ($left !== '' ? 'margin-left:' . $left . 'px;' : '') . ($right !== '' ? 'margin-right:' . $right . 'px;' : '');
    $block_size = getThumbSizes(array('thumb_size' => 'image_large', 'thumb_crop' => true, 'sidebar' => false));
    $image = getAttachmentID($image);
    if ($image != 'no') {
        $image_thumb = getResizedImageURL($image, $block_size['w'], $block_size['h']);
        $image_youtube = getVideoImgCode($url);
    }
    $start_frame = $image != 'no' ? true : false;
    $url = getVideoPlayerURL($src != '' ? $src : $url);
    $output = '';
    $video = '<div class="videoThumb"><video' . ($id ? ' id="sc_video_' . $id . '"' : '') . ' class="sc_video" src="' . $url . '" width="' . $width . '" height="' . $height . '"' . (is_single() ? $image != 'no' || sc_param_is_on($autoplay) ? ' autoplay="autoplay"' : '' : ($image != 'no' ? ' autoplay="autoplay"' : '')) . ($s != '' ? ' style="' . $s . '"' : '') . ' controls="controls"></video></div>';
    if ($width == '') {
        $width = $block_size['w'];
        $height = $block_size['h'];
    } else {
        if ($width == '' || ($width = '100%')) {
            $width = $block_size['w'];
            $height = $block_size['h'];
        }
    }
    if ($image && $image != 'no') {
        $video = substituteVideo($video, $width, $height, $start_frame);
        $output = getVideoFrame($video, $image_thumb, $title, $autoplay, $s);
    } else {
        if ($image != 'no') {
            $video = substituteVideo($video, $width, $height, $start_frame);
            $output = getVideoFrame($video, $image_youtube, $title, $autoplay, $s);
        } else {
            $output = $video;
        }
    }
    return $output;
}
// Extract gallery, video and audio from full post content
$post_gallery = $post_video = $post_audio = $post_url = $post_url_target = '';
if ($blog_style != 'fullpost') {
    if ($post_format == 'gallery') {
        $post_gallery = buildGalleryTag(getPostGallery($post_content_full, $post_id), $thumb_size[$blog_style]['w'], $thumb_size[$blog_style]['h']);
    } else {
        if ($post_format == 'video') {
            $post_video = getPostVideo($post_content_prepared, false);
            if ($post_video == '') {
                $src = getVideoPlayerURL(getPostVideo($post_content_prepared, true), $post_thumb != '');
                if ($src) {
                    $post_video = substituteVideo('<video src="' . $src . '">', $thumb_size[$blog_style]['w'], $thumb_size[$blog_style]['h']);
                }
            }
            if ($post_video != '' && get_custom_option('substitute_video') == 'yes') {
                $src = getVideoPlayerURL(getPostVideo($post_video), $post_thumb != '');
                if ($src) {
                    $post_video = substituteVideo('<video src="' . $src . '">', $thumb_size[$blog_style]['w'], $thumb_size[$blog_style]['h']);
                }
            }
        } else {
            if ($post_format == 'audio') {
                $post_audio = getPostAudio($post_content_prepared, false);
                if ($post_audio == '') {
                    $src = getPostAudio($post_content_prepared, true);
                    if ($src) {
                        $post_audio = substituteAudio('<audio src="' . $src . '">');
                    }
                }
                if ($post_audio != '' && get_custom_option('substitute_audio') == 'yes') {
                    $src = getPostAudio($post_audio);
示例#7
0
function sc_video($atts, $content = null)
{
    extract(shortcode_atts(array("id" => "", "url" => '', "src" => '', "autoplay" => '', "width" => '790', "height" => '391', "top" => "", "bottom" => "", "left" => "", "right" => ""), $atts));
    if ($src == '' && $url == '' && isset($atts[0])) {
        $src = $atts[0];
    }
    $s = ($top !== '' ? 'margin-top:' . $top . 'px;' : '') . ($bottom !== '' ? 'margin-bottom:' . $bottom . 'px;' : '') . ($left !== '' ? 'margin-left:' . $left . 'px;' : '') . ($right !== '' ? 'margin-right:' . $right . 'px;' : '');
    $url = getVideoPlayerURL($src != '' ? $src : $url);
    return '<video' . ($id ? ' id="' . $id . '"' : '') . ' class="sc_video" src="' . $url . '" width="' . $width . '" height="' . $height . '"' . ($autoplay > 0 && is_single() ? ' autoplay="autoplay"' : '') . ($s != '' ? ' style="' . $s . '"' : '') . ' controls="controls"></video>';
    /*
    	return '<iframe' . ($id ? ' id="' . $id . '"' : '') . ' class="sc_video" src="' . $url . '" width="' . $width . '" height="' . $height . '"'.($s!='' ? ' style="'.$s.'"' : '').' frameborder="0" webkitAllowFullScreen="webkitAllowFullScreen" mozallowfullscreen="mozallowfullscreen" allowFullScreen="allowFullScreen"></iframe>';
    */
}
示例#8
0
 function substituteVideo($post_text, $w, $h, $in_frame = true)
 {
     $tag = '<video>';
     $tag_end = '</video>';
     $pos_start = -1;
     while (($pos_start = themerex_strpos($post_text, themerex_substr($tag, 0, -1) . ' ', $pos_start + 1)) !== false) {
         $pos_end = themerex_strpos($post_text, themerex_substr($tag, -1), $pos_start);
         $pos_end2 = themerex_strpos($post_text, $tag_end, $pos_end);
         $tag_text = themerex_substr($post_text, $pos_start, ($pos_end2 !== false ? $pos_end2 + themerex_strlen($tag_end) - 1 : $pos_end) - $pos_start + 1);
         if (getTagAttrib($tag_text, $tag, 'data-frame') == 'no') {
             continue;
         }
         if (($src = getTagAttrib($tag_text, $tag, 'src')) == '') {
             $src = getTagAttrib($tag_text, $tag, 'url');
         }
         if ($src != '') {
             $auto = getTagAttrib($tag_text, $tag, 'autoplay');
             $src = getVideoPlayerURL($src, $auto != '');
             // && is_single());
             $id = getTagAttrib($tag_text, $tag, 'id');
             $tag_w = getTagAttrib($tag_text, $tag, 'width');
             $tag_h = getTagAttrib($tag_text, $tag, 'height');
             $tag_a = getTagAttrib($tag_text, $tag, 'align');
             $tag_s = getTagAttrib($tag_text, $tag, 'style');
             $video = '<iframe' . ($id ? ' id="' . $id . '"' : '') . ' class="video_frame' . ($tag_a ? ' align' . $tag_a : '') . '"' . ' src="' . $src . '"' . ' width="' . ($tag_w ? $tag_w : $w) . '"' . ' height="' . ($tag_h ? $tag_h : $h) . '"' . ' frameborder="0" webkitAllowFullScreen="webkitAllowFullScreen" mozallowfullscreen="mozallowfullscreen" allowFullScreen="allowFullScreen"></iframe>';
             if ($in_frame) {
                 $tag_image = getTagAttrib($tag_text, $tag, 'data-image');
                 $tag_title = getTagAttrib($tag_text, $tag, 'data-title');
                 $video = getVideoFrame($video, $tag_image, sc_param_is_on($tag_title), $tag_s);
             }
             $pos_end = $pos_end2 !== false ? $pos_end2 + 8 : $pos_end + 1;
             $post_text = themerex_substr($post_text, 0, themerex_substr($post_text, $pos_start - 3, 3) == '<p>' ? $pos_start - 3 : $pos_start) . $video . themerex_substr($post_text, themerex_substr($post_text, $pos_end, 4) == '</p>' ? $pos_end + 4 : $pos_end);
         }
     }
     return $post_text;
 }