0

我正在尝试在 wordpress 中使用外部媒体添加 vimeo 视频,视频链接是 http://vimeo.com/74626703,但它显示为错误加载播放器:找不到可播放的来源,所以我应该怎么做请帮忙。

function draw_video_contents($paged) {
global $post, $cat;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts(array('cat' => $cat . ',-' . CALENDAR_CATEGORY_ID, 'paged' => $paged,  'showposts' => 9));

$data = array();

// to display the entire text
global $more;    // Declare global $more (before the loop).
$more = 1;

if (have_posts()) : while (have_posts()) : the_post();
        $i++;

        ob_start();
        the_category(' ,');
        $categories = ob_get_clean();


        $data[] = array(
            "id" => $post->ID,
            "title" => get_the_title($post->ID),
            "link" => get_permalink($post->ID),
            "excerpt" => get_the_excerpt(),
            "description" => get_the_content(),
            "categories" => $categories,
            "tags" => get_the_tag_list('Tags: ', ', ', ''),
            "date" => get_the_time('M d y @ g:i A'),
            "author" => get_the_author_link(),
        );

    endwhile;
endif;


// Read the jwplayer tag into the posts, to get the mediaid
$media_id_list = array();
$video_list = array();


foreach ($data as $i => $d) {

    if (preg_match('/\[jwplayer mediaid="(\d*)".*\]/', $d['description'], $match)) {
        $mediaid = $match[1];
        $media_id_list[] = $mediaid;
        $data[$i]['mediaid'] = $mediaid;
        $data[$i]['mediatype'] = "jwplayer";
    } elseif (preg_match('/\[jwplayer file="(.*?)".*\]/', $d['description'], $match)) {
        $mediaid = $match[1];
        $data[$i]['mediaid'] = $mediaid;
        $data[$i]['mediatype'] = "jwplayer-file";
    } elseif (preg_match('#<iframe.*?src="(?:.*youtu.*?/embed/(.*?))".*?>#', $d['description'], $match)) {


        $mediaid = $match[1];
        list( $mediaid ) = explode("?", $mediaid);
        $data[$i]['mediaid'] = $mediaid;
        $data[$i]['mediatype'] = "youtube";
    } elseif (preg_match('#<iframe.*?src="(//player.vimeo.com/video/.*?)".*?>#',  $d['description'], $match)) {
        $mediaid = $match[1];
        $data[$i]['mediaid'] = $mediaid;
        $data[$i]['mediatype'] = "vimeo";
    }
}

// create the list of mediaid to use in the query
if ($query_in_media = implode(',', $media_id_list)) {
    global $wpdb;

    // get the mediafile URLs
    $request = "SELECT guid, ID
                    FROM wp_posts p
                    WHERE ID IN ($query_in_media)";

    $result = $wpdb->get_results($request);
    $media_list = array();
    foreach ($result as $r) {
        $media_list[$r->ID] = $r->guid;
    }

    // assign to $data the media_file
    foreach ($data as $i => $d) {
        if ($d['mediaid'] && isset($media_list[$d['mediaid']]))
            $data[$i]['media_file'] = $media_list[$d['mediaid']];
    }
}


$hugeImageSize = array('h' => 509, 'w' => 1024);
$smallVideoImageSize = array('h' => 167, 'w' => 256);

$largeImageSize = array('h' => 289, 'w' => 681);
$smallImageSize = array('h' => 205, 'w' => 340);
?>

 <div class="subHeaderBottomBorder"></div>

 <?php
 echo drawVideoItem($data[4], $hugeImageSize, "main");
 ?>
 <div class="videoCarousel">
    <ul id="videoCarousel">
    <?php echo drawSmallVideoItem($data[1], $smallVideoImageSize); ?> 
    <?php echo drawSmallVideoItem($data[2], $smallVideoImageSize); ?> 
    <?php echo drawSmallVideoItem($data[3], $smallVideoImageSize); ?> 

 <?php echo drawSmallVideoItem($data[5], $smallVideoImageSize); ?>  
 <?php echo drawSmallVideoItem($data[6], $smallVideoImageSize); ?>    
 <?php echo drawSmallVideoItem($data[7], $smallVideoImageSize); ?> 
    <?php echo drawSmallVideoItem($data[8], $smallVideoImageSize); ?>
 <?php echo drawSmallVideoItem($data[9], $smallVideoImageSize); ?> 
    </ul>
</div>
<div class="paginationWrapper">
    <a href="javascript:void(0);" class="previous">Previous</a>
    <a href="javascript:void(0);" class="next">Next</a>
</div>
</div>
4

1 回答 1

0

Have you tried shortcode?

[vimeo http://vimeo.com/44633289] doesn't work for me.

or

[embed]http://vimeo.com/9308198[/embed] works for me.

You can also check instructions here: http://en.support.wordpress.com/videos/vimeo/

p.s. what external media? Are you using some custom plugin? You should simply switch to html-edit mode and paste link to vimeo.

If it still doesn't work, try to switch to default theme and see if problem remains.

enter image description here

enter image description here

enter image description here

This is all I can do for you being, basically blindfolded :)

于 2013-09-18T07:12:31.307 回答