# Onebox Twitter embedding

**URL:** https://meta.discourse.org/t/onebox-twitter-embedding/18943
**Category:** Feature
**Created:** [August 17, 2014, 10:16am UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943 "2014-08-17T10:16:41Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![Apreche](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/apreche/32/106705_2.png) [@Apreche](https://meta.discourse.org/u/Apreche)
#### Post date: [January 2, 2017, 10:25pm UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/22 "2017-01-02T22:25:42Z")

</div>

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

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [January 3, 2017, 8:03am UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/23 "2017-01-03T08:03:08Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Apreche](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/apreche/32/106705_2.png) [@Apreche](https://meta.discourse.org/u/Apreche)
#### Post date: [January 3, 2017, 1:19pm UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/24 "2017-01-03T13:19:04Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Steven](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/steven/32/187890_2.png) [@Steven](https://meta.discourse.org/u/Steven)
#### Post date: [January 3, 2017, 2:19pm UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/25 "2017-01-03T14:19:46Z")

</div>

Some long tweets with images don’t work

> <https://twitter.com/discourse/status/793902121204711429>

Shorter tweets with images works

> <https://twitter.com/discourse/status/811048947695263745>

It exists since the [new twitter policy](https://blog.twitter.com/express-even-more-in-140-characters) regarding links and images in the 140 characters count

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [March 17, 2017, 9:01pm UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/26 "2017-03-17T21:01:52Z")

</div>

> [@Steven](#):
>
> Some long tweets with images don’t work

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

[https://github.com/discourse/discourse/pull/4766](https://github.com/discourse/discourse/pull/4766)

---

<div class="post-metadata">

### Author: ![ChrisBeach](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisbeach/32/214628_2.png) [@ChrisBeach](https://meta.discourse.org/u/ChrisBeach)
#### Post date: [March 18, 2017, 12:13am UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/27 "2017-03-18T00:13:42Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tjb1013](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tjb1013/32/120402_2.png) [@tjb1013](https://meta.discourse.org/u/tjb1013)
#### Post date: [April 19, 2017, 4:57pm UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/28 "2017-04-19T16:57:48Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Steven](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/steven/32/187890_2.png) [@Steven](https://meta.discourse.org/u/Steven)
#### Post date: [April 19, 2017, 6:30pm UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/29 "2017-04-19T18:30:09Z")

</div>

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

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [April 19, 2017, 6:47pm UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/30 "2017-04-19T18:47:53Z")

</div>

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

> [@Steven](#):
>
> 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

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.

---

<div class="post-metadata">

### Author: ![Steven](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/steven/32/187890_2.png) [@Steven](https://meta.discourse.org/u/Steven)
#### Post date: [April 19, 2017, 7:04pm UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/31 "2017-04-19T19:04:14Z")

</div>

It’s always the 1% left ![](https://global.discourse-cdn.com/meta/original/3X/5/e/5e441c87aef5c19df999ba360aa4d42a93c5eed9.png)

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [July 17, 2018, 8:57am UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/32 "2018-07-17T08:57:26Z")

</div>

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

> <https://twitter.com/discourse/status/944008301661974528>

---

<div class="post-metadata">

### Author: ![aatishrkamble](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aatishrkamble/32/140103_2.png) [@aatishrkamble](https://meta.discourse.org/u/aatishrkamble)
#### Post date: [July 19, 2019, 2:13pm UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/38 "2019-07-19T14:13:56Z")

</div>

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

[https://twitter.com/FUNimation/status/1151627642522755072](https://twitter.com/FUNimation/status/1151627642522755072)

How it appears on mobile:

 ![image](https://global.discourse-cdn.com/meta/original/3X/e/9/e90c6999eadc7c61c74d70e5956c64ddd377ba4f.png)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [July 31, 2019, 4:38am UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/39 "2019-07-31T04:38:05Z")

</div>

@awesomerobot is there a simple CSS fix for ⏫

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [October 3, 2019, 6:18pm UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/41 "2019-10-03T18:18:58Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [October 4, 2019, 11:15am UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/43 "2019-10-04T11:15:05Z")

</div>

> [@awesomerobot](#):
>
> 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

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

> <https://github.com/discourse/discourse/blob/30990006a92bd64eb6c49dc3139a17ce8fd1dc89/lib/twitter_api.rb#L29>

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

```html
<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?

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [October 4, 2019, 1:16pm UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/44 "2019-10-04T13:16:23Z")

</div>

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

---

<div class="post-metadata">

### Author: ![setanimals](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/setanimals/32/157130_2.png) [@setanimals](https://meta.discourse.org/u/setanimals)
#### Post date: [January 20, 2020, 7:25pm UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/46 "2020-01-20T19:25:45Z")

</div>

I’m trying to figure out how to make tweets pulled from zapier into a topic to appear like this and I’m having trouble. Anybody able to point me in the right direction? Should it work if I just enable “onebox” in settings?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [January 20, 2020, 7:31pm UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/47 "2020-01-20T19:31:08Z")

</div>

> [@setanimals](#):
>
> Should it work if I just enable “onebox” in settings?

> [@Onebox Twitter embedding](https://meta.discourse.org/t/onebox-twitter-embedding/18943/23):
>
> Disable enable twitter logins and just provide twitter consumer key & twitter consumer secret.

---

<div class="post-metadata">

### Author: ![smrtey](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@smrtey](https://meta.discourse.org/u/smrtey)
#### Post date: [February 26, 2020, 7:09pm UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/49 "2020-02-26T19:09:12Z")

</div>

Is there any way to get embedded tweets to show the tweet being replied to? For example, if I embed this tweet [https://twitter.com/AOC/status/1230329539924025345](https://twitter.com/AOC/status/1230329539924025345), in phpBB and vBulletin it displays both the tweet and what she’s responding to.  
pbpBB:

 ![image](https://global.discourse-cdn.com/meta/original/3X/8/2/82620793f2f08efda5d543e5f5d53fd4dab0b89f.png)

vB:

 ![image](https://global.discourse-cdn.com/meta/original/3X/0/8/08e53aa8c112dd3de5a433b5dd0fc04430da7116.png)

But in Discourse only the reply is shown, which often doesn’t make sense without the context of the original tweet

> <https://twitter.com/AOC/status/1230329539924025345>

Of course it’s easy enough to just post the original tweet as well as the reply, but most users (and a couple of twitter bots we use) aren’t clever/conscientious enough to figure out they need to do this.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [February 27, 2020, 4:47am UTC](https://meta.discourse.org/t/onebox-twitter-embedding/18943/50 "2020-02-27T04:47:42Z")

</div>

This is a very very tricky problem, the “official” twitter embed code has 2 problems

1. It does not provide us with height, so it would make topics jump around as it loads.
2. We would have to run twitter Javascript files on all our sites

We worked around this by using our own custom renderer, but unfortunately that means that we keep needing to play catch up with the official embed code.

[Previous page](https://meta.discourse.org/t/onebox-twitter-embedding/18943.md?page=1)

[Next page](https://meta.discourse.org/t/onebox-twitter-embedding/18943.md?page=3)
