# Wistia 视频在 Discourse 嵌入帖子中展示图片

**URL:** https://meta.discourse.org/t/wistia-video-showing-image-in-discourse-embedded-posts/282886
**Category:** Support
**Created:** [2023年十月20日 11:32 UTC](https://meta.discourse.org/t/wistia-video-showing-image-in-discourse-embedded-posts/282886 "2023-10-20T11:32:36Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![cyriac15](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cyriac15/32/334590_2.png) [@cyriac15](https://meta.discourse.org/u/cyriac15)
#### Post date: [2023年十月20日 11:32 UTC](https://meta.discourse.org/t/wistia-video-showing-image-in-discourse-embedded-posts/282886/1 "2023-10-20T11:32:36Z")

</div>

您好，

我已将 WordPress 文章集成到 Discourse 中。在其中一篇文章中，我添加了一个 Wistia 视频。它在 WordPress 文章中运行正常，但在 Discourse 中只显示图像。视频未显示，而是加载了一张图像。

有人能指导我吗？

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2023年十月20日 19:46 UTC](https://meta.discourse.org/t/wistia-video-showing-image-in-discourse-embedded-posts/282886/2 "2023-10-20T19:46:40Z")

</div>

感谢您询问此事。在调查此问题时，我发现 Discourse WordPress 插件在处理 YouTube 和 Vimeo 嵌入时存在问题。该问题的修复程序也可能解决了从 WordPress 发布的主题显示 Wistia 视频的问题。

我假设您正在使用 [WP Discourse](https://github.com/discourse/wp-discourse) 插件将帖子从 WordPress 发布到 Discourse，并且您已在 [WP Discourse](https://github.com/discourse/wp-discourse) 发布选项卡上启用了“使用完整帖子内容”选项。我还假设您使用的是 WordPress 区块编辑器，而不是经典编辑器。如果不是这样，请告诉我。

如果您正在将 WordPress 帖子发布到 Discourse，您是如何将 Wistia 视频添加到 WordPress 帖子的？您是使用“分享”链接还是使用视频的嵌入代码来添加视频？我认为如果使用“分享”链接，这个问题是可以解决的，但如果使用嵌入代码则不行。

供（我自己的）参考，YouTube 和 Vimeo 视频的问题在此处：

> <https://github.com/discourse/wp-discourse/blob/main/lib/discourse-publish.php#L281-L291>

当此代码添加到插件时，WordPress 视频区块的名称基于视频提供商。例如 `core-embed/youtube`。WordPress 现在似乎使用 `core/embed` 名称来表示视频区块，并通过 `providerNameSlug` 属性指定提供商。例如：

```plaintext
[blockName] => core/embed
[attrs] => Array
    (
        [url] => https://scossar3.wistia.com/medias/qtp20hbz4i
        [type] => video
        [providerNameSlug] => wistia-inc
    )

```

对 [https://github.com/discourse/wp-discourse/blob/main/lib/discourse-publish.php#L284C17-L284C35](https://github.com/discourse/wp-discourse/blob/main/lib/discourse-publish.php#L284C17-L284C35) 的以下更改修复了 YouTube 和 Vimeo 视频的问题，并且还允许将 Wistia 视频发布到 Discourse：

```plaintext
( 'core-embed/youtube' === $block['blockName'] || 'core-embed/vimeo' === $block['blockName'] || 'core/embed' === $block['blockName'] )

```

我只在我本地的开发站点上进行了更改。我会进一步研究它，看看是否可以将此修复程序添加到 [WP Discourse](https://github.com/discourse/wp-discourse) 插件的代码中。

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [2023年十月21日 03:40 UTC](https://meta.discourse.org/t/wistia-video-showing-image-in-discourse-embedded-posts/282886/3 "2023-10-21T03:40:59Z")

</div>

嘿 @cyriac15，你能分享一个你在 Wordpress 和 Discourse 上遇到此问题的示例吗？

---

<div class="post-metadata">

### Author: ![cyriac15](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cyriac15/32/334590_2.png) [@cyriac15](https://meta.discourse.org/u/cyriac15)
#### Post date: [2023年十月23日 12:58 UTC](https://meta.discourse.org/t/wistia-video-showing-image-in-discourse-embedded-posts/282886/4 "2023-10-23T12:58:28Z")

</div>

您好 @simon .. 感谢您的回复…  
是的…我正在使用 [WP Discourse](https://github.com/discourse/wp-discourse) 插件将帖子从 WordPress 发布到 Discourse。但我没有启用“使用完整帖子内容”选项，因为我在 WP 编辑器中使用了短代码。  
我目前正在使用 WP 经典编辑器…  
我正在使用 Wistia 嵌入代码到 WP 编辑器中添加视频。

我已经尝试了您提到的解决方案，但没有带来任何改变…

---

<div class="post-metadata">

### Author: ![cyriac15](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cyriac15/32/334590_2.png) [@cyriac15](https://meta.discourse.org/u/cyriac15)
#### Post date: [2023年十月23日 13:05 UTC](https://meta.discourse.org/t/wistia-video-showing-image-in-discourse-embedded-posts/282886/5 "2023-10-23T13:05:34Z")

</div>

您好 @angus ..  
我正在使用 [WP Discourse](https://github.com/discourse/wp-discourse) 插件从 Wordpress 发布帖子。  
嵌入的 Wistia 代码未在 Discourse 论坛中显示。请查看此 [链接](https://sierraconnect.staged-by-discourse.com/t/ipc-2223-standards-and-design-violations-for-rigid-flex-boards/167)。

 ![image](https://global.discourse-cdn.com/meta/original/4X/f/9/5/f957b78ca9c8514c13e4603b3d762c8dc8f31873.png)

截图中标示的图片是一个嵌入代码，但显示为一张图片。

我正在 wp 编辑器中使用 [嵌入链接](https://wistia.com/support/developers/embed-links)。

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2023年十月23日 19:17 UTC](https://meta.discourse.org/t/wistia-video-showing-image-in-discourse-embedded-posts/282886/6 "2023-10-23T19:17:52Z")

</div>

> [@cyriac15](#):
>
> 但我没有启用“使用完整帖子内容”选项，因为我在 WP 编辑器中使用短代码。

这是一个更难解决的问题。目前，当用户点击“显示完整帖子”按钮后，Discourse 在显示帖子时会剥离所有 iframe。这意味着来自任何来源的视频都将无法在主题中显示。如果能让它正常工作那就太好了。我知道这个问题已经被问过几次了。

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [2023年十月24日 00:42 UTC](https://meta.discourse.org/t/wistia-video-showing-image-in-discourse-embedded-posts/282886/7 "2023-10-24T00:42:38Z")

</div>

此问题发生的原因是，Discourse 中嵌入帖子的“显示完整帖子”按钮通过用户点击时“重新抓取”嵌入的网页来工作。点击该按钮时看到的 HTML 不是由 [WP Discourse](https://github.com/discourse/wp-discourse) 插件在帖子发布时发送的，而是对相关页面的全新抓取。

由于 HTML 结构的可能性多种多样（例如，显示图像的方式有很多种），网页抓取总是有一些不确定性。因此，这是一个正在考虑改进的功能。更多信息请参阅：

> [@Topic embedding needs some love](https://meta.discourse.org/t/topic-embedding-needs-some-love/262763):
>
> I was reminded of this today after clicking the “Show Full Post” button for [Introducing Discourse AI](https://meta.discourse.org/t/introducing-discourse-ai/262744). The full post that is displayed on Discourse is missing all images and many headings. Adding to the confusion, image captions are displayed, but without their associated images. It might be possible to fix the issue on Meta for its (Ghost?) blog by adjusting Meta’s allowed embed selectors site setting: [Configure the Allowed Embed Selectors Setting](https://meta.discourse.org/t/configure-the-allowed-embed-selectors-setting/134481). From past experience, I know that getting this…

因此，目前没有简单的解决方案。您可以尝试阻止和允许抓取器使用的 HTML 选择器，但这很难按您想要的方式使其正常工作。更多信息请参阅：

> [@How to customize the text in an embedded post?](https://meta.discourse.org/t/how-to-customize-the-text-in-an-embedded-post/214826/7#customize-what-html-is-pulled-from-your-site-1):
>
> Thanks for explaining Kevin. There are no settings specifically directed at this issue, but there’s two ways you could approach this. Customize what HTML is pulled from your site The way embeds work is that they scrape the content from a site using the [Readability](https://github.com/cantino/ruby-readability) gem. The gem and it’s output use the following options to filter what HTML is scraped opts[:whitelist] = SiteSetting.allowed\_embed\_selectors if SiteSetting.allowed\_embed\_selectors.present? opts[:blacklist] = SiteSetting.blocked\_embe…

解决此问题的更简单方法是隐藏“显示完整帖子”按钮，或使用自定义主题组件将其覆盖，使其链接回原始 WordPress 帖子。当一个网站具有相对复杂的帖子 HTML 结构（包括图像）时，例如您的网站，我倾向于建议采用后一种方案。
