Page MenuHomePhabricator

VisualEditor: Upload-by-insertion of images via copy-paste
Closed, ResolvedPublic8 Estimated Story Points

Description

[Suggestion from community.]

Copy-pasting in an image to the editor should automatically upload it to the wiki and insert it into the article.

After/on insertion (but before saving) the editor should be prompted to add meta-data (e.g. name, licence, source, ...).

I'd imagine we'd be less likely to accept this for Wikimedia wikis, but others (Wikia?) might be interested.

See Also: T23557: Paste image from clipboard Extension

Related Objects

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 22 2014, 12:26 AM
bzimport set Reference to bz37932.

Tweaking summary to clarify this is for HTML copy-paste -- if we get a full URL to the web then this should be doable. If we get a relative URL or something on the local filesystem, there's less we can do. :)

Drag-and-drop of files or similar would be a separate concern.

orbit wrote:

I've been taking copy-paste related tickets.

Interesting idea, I'll try to upload a first change for it :)

Change 288773 had a related patch set uploaded (by Florianschmidtwelzow):
WIP: Add possibility to paste a file to the document

https://gerrit.wikimedia.org/r/288773

Change 288773 had a related patch set uploaded (by Florianschmidtwelzow):
WIP: Add possibility to paste a file to the document

https://gerrit.wikimedia.org/r/288773

Change 339400 had a related patch set uploaded (by Jforrester; owner: Esanders):
[mediawiki/extensions/VisualEditor@master] Allow uploading of dropped Blobs

https://gerrit.wikimedia.org/r/339400

Change 288773 abandoned by Bartosz Dziewoński:
WIP: Add possibility to paste a file to the document

Reason:
Apparently no longer needed? https://gerrit.wikimedia.org/r/339400 also works. It's not clear to me why we couldn't do that before.

https://gerrit.wikimedia.org/r/288773

Change 339400 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] MWMediaTransferHandler: Allow uploading of dropped Blobs

https://gerrit.wikimedia.org/r/339400

@Florian Sorry to bother on this old ticket but I don't see how to do this in my current (1.31) installation of Mediawiki with Visual Editor enabled. Is this feature still in mediawiki or has it been taken out?

File upload by copy-paste definitely still exists and works, I just tested it. However, it seems like there is a bug and the media dialog opens on the wrong tab when a file is pasted (or dragged and dropped). You can still complete the upload if you switch to the other tab. See demonstration:


I filed T208286 about this issue.

(Also, we forgot to close this task in April 2017 when it was fixed, whoops.)

Hi @matmarex It does appear to work with copy pasting from paint but it doesn't work when copying pasting an image from another browser tab.

See recording here: https://cloud.jackalope.tech/s/example

Hi @matmarex It does appear to work with copy pasting from paint but it doesn't work when copying pasting an image from another browser tab.

Interesting. Turns out that when you copy an image in the browser, it is stored in the clipboard in two formats: as the actual image, and as HTML like this:

<html>
<body>
<!--StartFragment--><img src="https://apod.nasa.gov/apod/image/1705/Arp273Main_HubblePestana_3079.jpg" alt="Image result for galaxy"/><!--EndFragment-->
</body>
</html>

When this is pasted into VisualEditor, we use the HTML instead of the image (ve.ce.Surface.prototype.handleDataTransfer), because:

	// Only look for files if HTML is not available:
	//  - If a file is pasted/dropped it is unlikely it will have HTML fallback (it will have plain text fallback though)
	//  - HTML generated from some clients has an image fallback(!) that is a screenshot of the HTML snippet (e.g. LibreOffice Calc)

Then our paste sanitization strips that HTML down to nothing (since <img> tags using external resources are not possible in wikitext), and then nothing is pasted.

@Thedonquixotic Can you file a separate task about this?

(As a workaround, I guess you can paste into Paint, then copy from Paint.)

See recording here: https://cloud.jackalope.tech/s/example

(Here's the same, for future reference in case that URL becomes unavailable, and in smaller size to save folks a 200 MB download.)

@matmarex Will do. Thank you for the response :)