discourse/lib/onebox
Martin Brennan 2b04fbeb30
FIX: Use oEmbed for YouTube oneboxing (#35959)
We currently rely on Open Graph data to render YouTube oneboxes.
However, YouTube does not always give us a response with the Open Graph
data necessary, leading to empty preview HTML like this that shows
as a broken image in the composer:

```
<img src="" width="480" height="360" title=" - YouTube" style="aspect-ratio: 480 / 360;">
```

In addition, our old method of parsing YouTube script tags for JSON
which contains information for the video, introduced in

4d669d2b71,
seems to no longer work reliably, possibly due to changes in YouTube's
JS structure.

To fix this, we switch to using YouTube's oEmbed endpoint which gives us
all the metadata we need for oneboxes in JSON format, including title,
author,
thumbnail URL, and video dimensions. This approach is more robust and
less likely to break
due to changes in YouTube's page structure.

c.f.
https://meta.discourse.org/t/youtube-uris-fail-to-render-thumbnails-when-oneboxed/387673
2025-11-12 14:13:16 +10:00
..
engine FIX: Use oEmbed for YouTube oneboxing (#35959) 2025-11-12 14:13:16 +10:00
mixins UX: Improve git blob oneboxes (#30694) 2025-01-10 11:49:36 +00:00
templates DEV: Avoid empty p tag in github gist onebox (#35628) 2025-10-27 16:21:14 +01:00
domain_checker.rb DEV: Fix various rubocop lints (#24749) 2023-12-06 23:25:00 +01:00
engine.rb SECURITY: Restrict allowed URL patterns 2025-02-04 13:32:34 -03:00
file_type_finder.rb
helpers.rb DEV: Drop 'cache_onebox_response_body' feature (#32035) 2025-03-28 10:55:29 +00:00
json_ld.rb DEV: Replace custom Onebox blank implementation with ActiveSupport (#23827) 2023-10-07 19:54:26 +02:00
layout.rb DEV: Replace custom Onebox symbolize_keys implementation with ActiveSupport (#23828) 2023-10-09 09:32:09 +02:00
layout_support.rb
matcher.rb
movie.rb
normalizer.rb DEV: Replace custom Onebox blank implementation with ActiveSupport (#23827) 2023-10-07 19:54:26 +02:00
oembed.rb DEV: Replace custom Onebox symbolize_keys implementation with ActiveSupport (#23828) 2023-10-09 09:32:09 +02:00
open_graph.rb DEV: Replace custom Onebox blank implementation with ActiveSupport (#23827) 2023-10-07 19:54:26 +02:00
preview.rb DEV: Remove logical OR assignment of constants (#29201) 2024-10-16 10:09:07 +08:00
sanitize_config.rb DEV: Bump rubocop_discourse (#29608) 2024-11-06 06:27:49 +08:00
status_check.rb
template_support.rb
view.rb