简体   繁体   English

在Wordpress中删除iframe广告代码

[英]Removing iframe tags in Wordpress

I am working on a wordpress theme and WP now uses oEmbed to automatically turn known links into widgets. 我正在研究wordpress主题,并且WP现在使用oEmbed自动将已知链接转换为小部件。 The problem here is that the widgets are not responsive (they do not keep the same aspect ratio and adjust to the screen size). 这里的问题是小部件没有响应(它们没有保持相同的宽高比并且无法调整为屏幕大小)。

The site is http://testsite1.seyoum.net/ Note that the theme I am using is a child theme of twentyfifteen. 该站点为http://testsite1.seyoum.net/注意,我使用的主题是25的子主题。 You can download the theme files here: https://onedrive.live.com/redir?resid=B9CDD4D34FF06A75!97938&authkey=!AEj9VpYkCRL0SEE&ithint=file%2crar 您可以在此处下载主题文件: https : //onedrive.live.com/redir?resid=B9CDD4D34FF06A75!97938&authkey=!AEj9VpYkCRL0SEE&ithint= file% 2crar

I have done some research and found this video: https://youtu.be/Dm0YnuQeROI In the video he removes the with and height properties of the iframe. 我做了一些研究,发现了这个视频: https : //youtu.be/Dm0YnuQeROI在视频中,他删除了iframe的with和height属性。 The problem for me is that these tags are added automatically by oEmbedd so I need some kind of filter that removes/ignores the height and width tags in the iframe. 对我来说,问题是这些标签是由oEmbedd自动添加的,因此我需要某种过滤器来删除/忽略iframe中的高度和宽度标签。

I am trying to alter an iframe. 我正在尝试更改iframe。 More spesifically I want to remove the height and width tags of the iframe by using (what I believe to be) filters. 更具体地说,我想通过使用(我相信是)过滤器来删除iframe的高度标签和宽度标签。

Example: I want to change this 例子:我想改变这个

<iframe width="660" height="400" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?visual=true&amp;color=000000&amp;download=false&amp;show_user=false&amp;sharing=false&amp;show_comments=false&amp;show_playcount=false&amp;hide_related=true&amp;url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F192992432&amp;show_artwork=false&amp;&amp;"></iframe>

To this: (The width="660" height="400" is gone) 为此:(宽度=“ 660”高度=“ 400”消失了)

<iframe scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?visual=true&amp;color=000000&amp;download=false&amp;show_user=false&amp;sharing=false&amp;show_comments=false&amp;show_playcount=false&amp;hide_related=true&amp;url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F192992432&amp;show_artwork=false&amp;&amp;"></iframe>

I am not familiar with php and it is hard to find articles I can understand so please help me out if you can. 我不熟悉php,很难找到我能理解的文章,因此,如果可以,请帮助我。

Try to use 尝试使用

function mycustom_embed_defaults($embed_size){ 
    // Applies for all embedded media 
    /*$embed_size['width'] = 827;*/ // Adjust the width of the player 
    // $embed_size['height'] = 120; // Adjust the height of the player 
    unset($embed_size['width']); 
    unset($embed_size['height']); 
    return $embed_size; // Return new size 
}

or 要么

function mycustom_embed_defaults($embed_size){ 
    // Applies for all embedded media 
    $embed_size['width'] = "auto"; // Adjust the width of the player 
    $embed_size['height'] = "auto"; // Adjust the height of the player 
    return $embed_size; // Return new size 
}

or 要么

function mycustom_embed_defaults($embed_size){ 
    // Applies for all embedded media 
    $embed_size['width'] = "100%"; // Adjust the width of the player 
    $embed_size['height'] = "100%"; // Adjust the height of the player 
    return $embed_size; // Return new size 
}

The problem is that your plugin seems to need the width property... All you have to do is to know what you want it to be... It doesn't have to be a pixel value... 问题是您的插件似乎需要width属性...所有您需要做的就是知道您想要的是什么...它不必是像素值...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM