[英]Exclude Soundcloud from javascript code
Recently implented this javascript code in order to make all my video embeds the same size as my images. 最近实现了这个javascript代码,以使我的所有视频嵌入与我的图像相同的大小。 bhyphen.com
bhyphen.com
<script language='javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js' type='text/javascript'/>
<script type='text/javascript'>//<![CDATA[
$(document).ready(function() {
// change the dimension variable below to be the column size you want
var newwidth= 660;
// this identifies the post-body div element, finds each image in it, and resizes it
$('.post-body').find('iframe').each(function(n, iframe){
var iframe = $(iframe);
var height = iframe.attr('height');
var width = iframe.attr('width');
var newHeight = (height/width * newwidth).toFixed(0);
iframe.attr('width',newwidth).attr('height',newHeight);
});
});
//]]></script>
This code as also affected my Soundcloud embeds as well. 这段代码也影响了我的Soundcloud嵌入。 Is there a piece of code I can add so that the iframes from my SC embeds will be ignored?
是否有一段代码我可以添加,以便我的SC嵌入的iframe将被忽略?
Instead of $('.post-body').find('iframe)
try classing your Soundcloud and Videos separately: 而不是
$('.post-body').find('iframe)
尝试分别对Soundcloud和Videos进行分类:
$('post-body').find('#iframe-videos')
With your iframe changed to <iframe class='iframe-videos'>
将iframe更改为
<iframe class='iframe-videos'>
That way your script will only affect your videos, not all iframes. 这样,您的脚本只会影响您的视频,而不会影响所有iframe。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.