【问题标题】:Customizing jquery-oembed-all to my needs根据我的需要自定义 jquery-oembed-all
【发布时间】:2014-02-21 13:25:16
【问题描述】:

我在我的页面中使用 jquery-oembed-all 来播放 youtube/vimeo 视频。它的大小比我需要的大一些或更大。我尝试更改持有aclass 的css 属性,但没有成功。虽然我可以通过在 css 中选择 iframe 来更改 iframe 的高度和宽度。但是玩家并没有缩小。还有一个向上和向下箭头符号来隐藏/取消隐藏 iframe 播放器,我不想在我的页面中使用它。如何根据需要自定义 jquery-oembed-all

或者还有其他方法可以实现吗?

任何帮助将不胜感激。谢谢!

html:

<div id="videos">
        <div id="video_wrapper">
            <div class="video_container">
                <a href="http://www.youtube.com/watch?v=hWnAqFyaQ5s" class="embed" class="video"></a>
                <p><a href="">This is the title</a></p>
                <p>2 days ago</p>
            </div>
            <div class="video_container">
                <a href="http://vimeo.com/86290699" class="embed video"></a>
                <p><a href="">This is the title</a></p>
                <p>2 days ago</p>
            </div>
        <div class="clear_left"></div>
        </div>
</div>

css:

#videos #video_wrapper .video_container .video {
    width: 180px;
}

【问题讨论】:

  • 您的&lt;a&gt; 中不应有两个类属性,而不是class="embed video"
  • 我的错!谢谢你。已更正。

标签: jquery html css oembed


【解决方案1】:

当您在 .js 文件中调用 oembed() 方法时,您可以指定一些设置。 这里有一些默认设置:

$.fn.oembed.defaults = {
    maxWidth: null,
    maxHeight: null,
    includeHandle: true,
    embedMethod: 'auto',
    // "auto", "append", "fill"     
    onProviderNotFound: function() {},
    beforeEmbed: function() {},
    afterEmbed: function() {},
    onEmbed: false,
    onError: function() {},
    ajaxOptions: {}
};

如您所见,我们可以指定 ma​​xWidth,因此您的代码如下所示:

$('a.embed').oembed(null,{
   maxWidth: 180
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多