javascript - Twitter 嵌入(使用 wordpress)并加载?

标签 javascript jquery wordpress twitter embed

我想知道推文何时加载。 我有这种帖子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>&mdash; 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/

相关文章:

WordPress API 错误 : "Sorry, you are not allowed to create new posts."

javascript - 砌体布局中的中心单列

javascript - 如何获取 RxJS Subject 或 Observable 的当前值?

javascript - 如何在进度条全屏表单界面上添加百分比状态

jquery - 如何从 Controller 调用 jQuery(从 Devise 注册路径后)?

javascript - 表头上的切换按钮仅在 2 次切换后才有效

html - 并排 float 无符号列表中的 2 个元素

wordpress - 如何修复 Gutenberg block 错误 - 组件正在将不受控制的 url 类型输入更改为受控

javascript - PassportJS/Express 内部出错后如何重定向?

javascript - 生成 SVG 形状