繁体   English   中英

在Wordpress中删除iframe广告代码

[英]Removing iframe tags in Wordpress

我正在研究wordpress主题,并且WP现在使用oEmbed自动将已知链接转换为小部件。 这里的问题是小部件没有响应(它们没有保持相同的宽高比并且无法调整为屏幕大小)。

该站点为http://testsite1.seyoum.net/注意,我使用的主题是25的子主题。 您可以在此处下载主题文件: https : //onedrive.live.com/redir?resid=B9CDD4D34FF06A75!97938&authkey=!AEj9VpYkCRL0SEE&ithint= file% 2crar

我做了一些研究,发现了这个视频: https : //youtu.be/Dm0YnuQeROI在视频中,他删除了iframe的with和height属性。 对我来说,问题是这些标签是由oEmbedd自动添加的,因此我需要某种过滤器来删除/忽略iframe中的高度和宽度标签。

我正在尝试更改iframe。 更具体地说,我想通过使用(我相信是)过滤器来删除iframe的高度标签和宽度标签。

例子:我想改变这个

<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>

为此:(宽度=“ 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>

我不熟悉php,很难找到我能理解的文章,因此,如果可以,请帮助我。

尝试使用

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 
}

要么

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 
}

要么

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 
}

问题是您的插件似乎需要width属性...所有您需要做的就是知道您想要的是什么...它不必是像素值...

暂无
暂无

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

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