如何使用base64对wordpress中的视频URL进行编码?

时间:2015-03-24 22:36:58

标签: php wordpress base64

<?php
$vid = get_post_meta($post->ID,'videourl', true);
$video = base64_encode($vid); 
$embedvideo =  get_post_meta($post->ID,'embedvideo', true);
$sefurL = get_bloginfo('template_url', true);
if($video != "") {  ?>
<?php if ( !wp_is_mobile() ) { 
echo'<object id="player" width="800" height="500" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
    <param name="flashvars" value="file='.$video.' />
    <param name="allowfullscreen" value="true" />
    <param name="allowscriptaccess" value="always" />
    <param name="src" value="'.$sefurL.'/inc/tools/jwplayer/player.swf" />
    <embed src="'.$sefurL.'/inc/tools/jwplayer/player.swf" autostart=false" wmode="opaque" allowscriptaccess="always" quality="high" FlashVars="file='.$video.'&width=800&height=500&skin='.$sefurL.'/inc/tools/jwplayer/blueratio.zip&repeat=false&autostart=false&image=big=true" quality="high" bgcolor="#000" width=800 height=500 name="jwplayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" allowfullscreen=true />
</embed>
</object>'; 
} else {
echo '<video src="'.$video.'" controls>
      Your browser does not support the <code>video</code> element.
     </video>';
} 
?>
<?php } elseif($video == "" && $embedvideo != "") { ?>
<?php echo $embedvideo; ?>
<?php } else {
wpautop(the_content());
} ?>

正如您在代码中看到的那样,我使用了$video = base64_encode($vid);但是当我这样做时,视频无法正常工作,所以我没有任何使用过我在谷歌上搜索过的base64编码的经验但我无法找不到合适的方法。

任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

也许你应该使用base_64_decode(),它可能是&#39; videourl&#39;已经base64编码。了解base64_encode()的工作原理 PHP Docs

尝试回显$ vid的值,以确定它是否已经是base64编码。