Onebox Twitter embedding

Oh, thanks! Is it possible to do that without actually allowing Twitter logins?

Disable enable twitter logins and just provide twitter consumer key & twitter consumer secret.

3 « J'aime »

Tried it. It didn’t work. Embedded tweets still do not contain images.

Some long tweets with images don’t work

Shorter tweets with images works

It exists since the new twitter policy regarding links and images in the 140 characters count

6 « J'aime »

I’ve just submitted a PR which should fix this:

10 « J'aime »

@david - thank you! We do a lot of Twitter oneboxing and found the truncation very annoying.

4 « J'aime »

This is terrific - my forum users really need this.

Is this merged into a future release or something we have to do to modify in our existing installations?

Just upgrade on latest version, it should be good :

  • via yourforum.com/admin/upgrade
  • or SSH into your server and do these commands :

cd /var/discourse
git pull
./launcher rebuild app

I don’t think you need to add the twitter consumer key and twitter consumer secret in your admin settings but I’m only 99% sure

2 « J'aime »

Yep - it’s all merged into master and working great on my forum

I’m afraid you will need to add these keys to your site settings - the data is fetched via the twitter API rather than opengraph/oembed.

2 « J'aime »

It’s always the 1% left

1 « J'aime »

I just pushed a small improvement for Twitter onebox. The onebox will now show like and retweet count.

11 « J'aime »

Twitter onebox with videos are really long on mobile. Here’s one I am adding to this post.

How it appears on mobile:

5 « J'aime »

@awesomerobot is there a simple CSS fix for :arrow_double_up:

4 « J'aime »

At the moment on mobile we set a max-height (70vh) and 100% width, and the video scales to fit. This works better for portrait oriented videos than landscape.

We can assume most videos will be landscape, but then we crop portrait oriented videos pretty severely as a trade-off.

There’s no simple fix for both without knowing the aspect ratio (Are we able to calculate the aspect ratio of these and maybe append a style based on that? the iframe seems to come with height/width).

4 « J'aime »

Yes, we can do that. This is the line where we build the iframe

What HTML structure would be most useful for you @awesomerobot? Something like

<div class='tweet-images'>
  <div class='aspect-image-full-size' style='--aspect-ratio:#{width}/#{height};'/>
    <iframe class='tweet-video' src='https://twitter.com/i/videos/blah' width='123' height='456' frameborder='0' allowfullscreen></iframe>
  </div>
</div>

And then we can re-use the aspect-image-full-size logic which we use for images?

1 « J'aime »

Yeah I think that could work, with the aspect ratio there I should be able to adjust as needed.

2 « J'aime »

J’essaie de comprendre comment faire en sorte que les tweets importés via Zapier s’affichent sous forme de sujet comme ceci, mais je rencontre des difficultés. Quelqu’un pourrait-il m’orienter dans la bonne direction ? Est-ce que cela devrait fonctionner si j’active simplement l’option « onebox » dans les paramètres ?

3 « J'aime »

Existe-t-il un moyen d’afficher le tweet auquel on répond lors de l’intégration de tweets ? Par exemple, si j’intègre ce tweet https://twitter.com/AOC/status/1230329539924025345, phpBB et vBulletin affichent à la fois le tweet et celui auquel elle répond.
phpBB :

vB :

Mais dans Discourse, seul le tweet de réponse est affiché, ce qui n’a souvent aucun sens sans le contexte du tweet original.

Bien sûr, il est assez simple de publier également le tweet original en plus de la réponse, mais la plupart des utilisateurs (ainsi que quelques bots Twitter que nous utilisons) ne sont pas assez avisés ou consciencieux pour comprendre qu’ils doivent le faire.

7 « J'aime »

Ceci est un problème très, très délicat : le code d’intégration « officiel » de Twitter présente deux problèmes :

  1. Il ne nous fournit pas la hauteur, ce qui fait que les sujets bougent pendant le chargement.
  2. Nous devrions exécuter les fichiers JavaScript de Twitter sur tous nos sites.

Nous avons contourné cela en utilisant notre propre rendu personnalisé, mais malheureusement, cela signifie que nous devons continuellement rattraper le code d’intégration officiel.

6 « J'aime »