[英]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&color=000000&download=false&show_user=false&sharing=false&show_comments=false&show_playcount=false&hide_related=true&url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F192992432&show_artwork=false&&"></iframe>
為此:(寬度=“ 660”高度=“ 400”消失了)
<iframe scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?visual=true&color=000000&download=false&show_user=false&sharing=false&show_comments=false&show_playcount=false&hide_related=true&url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F192992432&show_artwork=false&&"></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.