10

I want to embed a tweet with an image. When I embed a tweet on a blogdown post using shortcodes it does not appear in the twitter style

For example using the shortcode:

{{< tweet 989470885475008512 >}} 

I get an output (my blogdown uses the academic theme)

enter image description here

rather than this (as shown in the blogdown guide)...

enter image description here

Is there a way to override this behavior to get the appearance like this second example or to embed a tweet following the dev titter guidelines (which when I paste the html code in gives output like the first image above).

I am guessing, but I think the loss of twitter style in the embedded tweet restricts the possibility to embed a tweet with an image (it gives similar output to the first example along with the image url).

UPDATE

This is a browser (Firefox) issue (as suggested by @hplieninger). The twitter style appears when viewing the page in Chrome.

prosoitos
  • 6,679
  • 5
  • 27
  • 41
guyabel
  • 8,014
  • 6
  • 57
  • 86
  • 1
    Have you tried to open the blog post using different browsers with different settings? I sometimes observe the same thing, but I think it is related to my restrictive Firefox privacy-setup. – hplieninger May 02 '18 at 06:56
  • I've also found RStudio doesn't render it completely in its viewer. Try opening it via a browser. – Harshvardhan Jan 11 '22 at 18:08

2 Answers2

7

Try this:

```{r echo=FALSE}
blogdown::shortcode('tweet', '989470885475008512')
```

Should work.

lcgodoy
  • 763
  • 5
  • 14
  • I'm fairly sure that just {{% tweet 1281252614349426689 %}} will work. If you wanted a slightly lighter syntax. – DX101 Jul 12 '20 at 10:05
6

Instead of copying the id of the tweet, simply click the drop-down icon at the top-right of the tweet, then select "Embed Tweet", copy the code and paste it into your markdown post. Go to your browser and you should see the effect.

enter image description here

Peoray
  • 1,705
  • 2
  • 12
  • 21