2011-11-25 91 views
1

所以,我发现这个工具,可以自动从HTML页面调整大小的iframe:如何在wordpress页面中使用easyxdm跨域自动调整iframe的大小?

http://consumer.easyxdm.net/current/example/resize_iframe.html

但是,当我按照他们的例子也不会在WordPress工作。

有谁知道如何使它工作或有一个替代方法,与嵌入WordPress内的iframe一起工作?

+0

我发现了一个惊人的解决方案,它完美的作品。 http://stackoverflow.com/questions/153152/resizing-an-iframe-based-on-content – Kyoku

+0

结束了使用此解决方案: http://stackoverflow.com/questions/153152/resizing- an-iframe-based-content – Kyoku

+0

您是否包含easyXDM.js?我使用easyXDM作为WordPress插件的一部分,它似乎工作正常。 – colllin

回答

0

添加此添加到functions.php它会发现宽度= 560和高度= 315每一个IFRAME并将其更改为WIDTH = 600 HEIGHT = 338

function add_youtube_size($youtubehtml) { 
    if (strpos($youtubehtml, "<iframe") !== false) { 
     $youtubesearch = array('width="560"', 'height="315"'); 
     $youtubereplace = array('width="600"', 'height="338"'); 
     $youtubehtml = str_replace($youtubesearch, $youtubereplace, $youtubehtml); 

     return $youtubehtml; 
    } else { 
     return $youtubehtml; 
    } 
} 
add_filter('the_content', 'add_youtube_size', 10);