A user, merefield, reported an issue with Onebox and YouTube, where the thumbnail fails to show up on the Topic List for certain themes and plugins. The issue appears to be related to a recent regression in Discourse or Onebox and is not present in prior builds. merefield identified the problematic commit through a Git Bisect and Falco pointed out the specific code change that caused the issue.
The change replaced the post.post_analyzer.found_oneboxes? method with a CSS selector approach, which fails to detect oneboxes that use oembed or iframe. codinghorror and Falco expressed concerns about the fragility of this change.
nbianca explained the reasoning behind the change, which was to prevent awarding the “First Onebox” to any posted link. However, nbianca later acknowledged that the change broke the detection of oneboxes and created a PR to fix the issue.
Further investigation revealed that the issue is not solely related to the Onebox change, but also involves the TLP plugin and its overrides. merefield and nbianca discussed the possibility that the TLP plugin was relying on a changed behavior.
The issue was eventually fixed with a PR, as confirmed by nbianca.
Youtube thumbnail fails to show up on Topic List for e.g. Fakebook theme, TLP plugin.
STR:
Post a youtube video, switch to Fakebook Theme, no thumbnail appears.
Workaround:
Rebuild the post and the thumbnail appears, however, given users are expecting the thumbnail to appear imminently without staff intervention, this is not a great solution.
More info:
Topic.image_url appears to be nil
This seems to have broken recently, after beginning of August … I think this worked before August the 5th (but not sure when it actually broke). I’ve noticed this aligns roughly with a new version of Onebox …
I tested this on a prior build and the issue was not present, ruling out Youtube og responses I hope. Also Fakebook theme shows the same behaviour as TLP plugin, ruling out TLP plugin, so I do suspect it’s a recent regression in Discourse or Onebox.
This is a real issue for users of Topic List Previews.
@nbianca why did we don’t use the post.post_analyzer.found_oneboxes? method anymore in here?
All oneboxes which use either oembed or iframe will fail the new CSS selector mode, and that also makes our Onebox detector be different across the codebase.
The problem was that the First Onebox was awarded for any posted link, no matter if it was or was not a Onebox. This happens because PrettyText adds class="onebox" to all links and then Oneboxer tries to parse all links with class onebox.
The change I made checks if the final document has any Oneboxes (Oneboxes are aside with class onebox). I will have another look and see what and why is it broken and come back with a change that fixes both of the issues.
I just tested v2.3.2 and it does not look like YouTube links set the image_url attribute of the topic. The reason is that the image is extracted from the src attribute of an img, but when a YouTube video is linked, there is a <div> with a background-image CSS attribute.