Allow pasting of GIFs into composer

AI-generated summary

The discussion revolves around enabling the pasting of GIFs into the Discourse composer by using their source URL instead of a static image. Falco explains that while browsers copy GIFs as both a static image and an HTML img tag, Discourse currently uploads the static image, losing animation. He proposes a solution via a PR (#16204) to paste the GIF URL directly, preserving animation. Danielabc initially asks for clarification on PRs, and JammyDodger clarifies that the change is already live in the latest version. Danielabc confirms the update works well, praising the improved usability and ability to use GIFs from other users. PaulinaMX also supports the change with a GIF example.

Continuing the discussion from Is it possible to paste images as their source address?:

If you right click and select “Copy Image” on a GIF you found on the internet with your browser, your clipboard will be populated with two elements:

  1. A static PNG image of the GIF as image/png
  2. An HTML img tag with the GIF source as text/html

For most use cases, it’s a far better user experience to pick the option 1 in the clipboard and upload that image right away in the composer, so that is what we always do. However, for animated GIFs we may want to invert the logic and paste the image source address, so the animation isn’t completely lost.

Example of the contents in the clipboard JS event after copying a random GIF from Google Image Search:

<img src=\"https://c.tenor.com/tX_T48A14BwAAAAd/khaby-really.gif\" alt=\"Khaby Really GIF - Khaby Really - Discover &amp;amp; Share GIFs\" jsaction=\"load:XAeZkd;\" jsname=\"HiaYvf\" class=\"n3VNCb\" data-noaft=\"1\" style=\"width: 389px; height: 389px; margin: 0px;\">

The BBPress composer have this feature, so we have to catch up!

10 Likes

It would be much better if that happened.

3 Likes

I have a PR up with a proposed solution:

https://github.com/discourse/discourse/pull/16204

5 Likes

Before:

After:

Can you give it a try @danielabc ?

5 Likes

Good thing you speak Portuguese lol
I feel a bit lost here, what is PR? Paraná? LOL

Is this link you sent me a plugin? Do I have to install it?

Thank you

1 Like

No plugin, you just need to update to Latest. :slightly_smiling_face::+1:

1 Like

As our colleague said, just update your Discourse.

2 Likes

Seriously, they modified Discourse just because of me? How fancy, lol

What does PR mean? Does it mean a tip for them to fix something? Can I also give tips?

Something like a “change proposal.” When you submit a change to software code so that it includes a new feature or fixes a bug.

In this case, I wrote this functionality and submitted it as a PR, which is reviewed by other colleagues at the company and finally incorporated into the software.

Great! :heart:

1 Like

I tested it here and YOU ARE TO BE CONGRATULATED! This change greatly improved the usability of the forum, now members can even use gifs uploaded by other members on the forum itself! It looks SENSATIONAL! (Before it didn’t work, it was a frozen image lol) Thank you very much!

1 Like