我想知道推文何时加载。 我有这种帖子http://pego-design.com/remarky-brisi/media-twitter-embeds/或这里 http://en.support.wordpress.com/twitter/twitter-embeds/ 并且想知道通过这段代码创建的 strange iframe 的高度:
<div class="entry-content">
<blockquote class="twitter-tweet" width="550"><p>Really cool to read through and find so much awesomeness added to WordPress 3.6 while I was gone. I should take three weeks off more often.</p>
<p>— Andrew Nacin (@nacin) <a href="https://twitter.com/nacin/status/319508408669708289">April 3, 2013</a></p></blockquote>
<p><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script></p>
丑陋的 js 演示:http://jsfiddle.net/qWHc5/2/
如果你检查这个演示,你可以看到 iframe 的第一个和最终大小(93,213,213,213… 或 93,93,93,213,213…),我需要知道如何在没有丑陋解决方案的情况下获得最后一个值。
我试试这个 How can I detect whether an iframe is loaded?但不起作用……
更新:我找到了这个版本的widgets.js https://gist.github.com/johan/4479186我不知道如何使用回调,就像这样 window.twttr.tfw.callbacks.cb0
。
最佳答案
WordPress 使用 oEmbed 将 twitter 包含在 others 中.
您可以在 wp-includes/class-oembed.php
要影响它使用:
function so_17151843_embed ( $provider, $url, $args ) {
// check $provider if it is twitter
// change url values to what you want
$url = add_query_arg( 'maxheight', $url )
return $url;
}
add_filter( 'oembed_fetch_url', 'so_17151843_embed' );
你可以把它放在你的 functions.php
中。
这应该对您有所帮助。
关于javascript - Twitter 嵌入(使用 wordpress)并加载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17151843/