claas noted that with the release of Firefox 50 (stable in November 2016, available in Developer Edition and Nightly from September), the existing firefoxPastingHack for image pasting in Discourse would become unnecessary due to the implementation of clipboardData.items. However, they highlighted a temporary issue where pasting images in Firefox 50 resulted in duplicate instances (typically three) because the paste event contained both PNG and JPEG versions. sam suggested switching from user agent detection to feature detection as a more robust solution. claas agreed that feature detection would be ideal, but noted that adding a version constraint would suffice if feature detection wasn’t immediately feasible. Ultimately, claas confirmed that the issue has been resolved in both the Discourse codebase and Firefox, allowing the topic to be closed.
There is still some time until Firefox 50 becomes stable in November 2016, but as a noteworthy number of developers could use it already from September when it will promoted to Firefox Developer Edition (in fact, I’m using it already with Firefox Nightly), I suppose it is not too early to point out that the following firefoxPastingHack for pasting images will not be necessary (and even counterproductive) any more due to clipboardData.items being implemented in Firefox 50 (see Mozilla Bug 906420):
This said, pasting an image into Discourse using Firefox 50 currently yields two to four (mostly three) instances of the same image being inserted:
This is due to the fact that the paste event contains both a png and a jpeg version of the image. Whether this is intended or not, is expected to be cleared very soon (in Mozilla Bug 1290688) and so we can anticipate a fix or (if it’s a feature) a hint on how to solve this conceptually.