dongtan2017 2013-07-03 14:11
浏览 46

Wordpress - 过滤视频嵌入代码

In Wordpress, how do you filter a textarea that saves a vimeo embed code in theme admin? Using sanitize_text_field will make the code unusable when saving into db via update_post_meta.

    $postmeta = sanitize_text_field( $_POST['embed_video']);
    update_post_meta($post_id, 'embed_video',$postmeta );
  • 写回答

2条回答 默认 最新

  • dongqiang4986 2013-07-03 15:04
    关注

    I often approach wordpress video embeds from the other angle, creating the embed code in the template, for example rather than have someone embed a video like this:

    <iframe src="http://player.vimeo.com/video/69277800?title=0&amp;byline=0&amp;portrait=0&amp;badge=0" width="577" height="325" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
    

    I'd have them just insert the id, in this case 69277800. Then I'd put in my template

    <?php if(!empty($video_id)):?>
    <iframe src="http://player.vimeo.com/video/<?php echo $video_id;?>?title=0&amp;byline=0&amp;portrait=0&amp;badge=0" width="577" height="325" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
    <?php endif;?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数