Page MenuHomePhabricator

VisualEditor: Support magic pasting of HTML that contains a transclusion of or link to a wiki image
Open, MediumPublicFeature

Description

Right now if you have some rich content with an image and paste it into VisualEditor, we discard the image.

However, it'd be nice to add some special handling in VisualEditor's paste for the HTML of images so that those from Commons used on a MediaWiki instance get sought out and inserted instead.

Perhaps via a special custom attribute VE would sniff for, that would make VE try to find the image from Commons (if the wiki was configured for InstantCommons), or other fileRepos?

MediaViewer's "embed" HTML looks like:

If we asked them to add an attribute, e.g. (simplified):

<p><a href="…"><img src="…" alt="…" ve-data="ve-pastableImage" ></a>[…]</p>

… could we do this?

(Also, yes, they should be using <figure> instead of <p><img></p>.)


Version: unspecified
Severity: enhancement

Details

Reference
bz64935

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 3:20 AM
bzimport set Reference to bz64935.

Granted, MediaViewer's HTML format is total crap, but there isn't a clean, semantic way to mark up image captions that works in HTML4. Maybe browsers these days understand HTML5 tags no matter the doctype, and using figure is fine - we should look into that.

At any rate, whether it is in a figure tag figure or something else, users would probably expect the caption to end up inside the image wikicode, not as a HTML wrapper. So I suppose the caption would need special attributes as well?

(In reply to Tisza Gergő from comment #1)

At any rate, whether it is in a figure tag figure or something else, users
would probably expect the caption to end up inside the image wikicode, not
as a HTML wrapper. So I suppose the caption would need special attributes as
well?

Sure, or we could fetch the caption from Commons in the context language automatically, so users don't have to be using the right language?

We tried to avoid using the description where a caption is available; the description is often less relevant and too verbose. Also, the caption might be in the right language - copy-pasting images does not necessarily happen across wikis. (I guess we could add a lang attribute, which is a sensible thing to do anyway, and then language mismatch could be detected on paste.)

(In reply to Tisza Gergő from comment #3)

We tried to avoid using the description where a caption is available; the
description is often less relevant and too verbose. Also, the caption might
be in the right language - copy-pasting images does not necessarily happen
across wikis. (I guess we could add a lang attribute, which is a sensible
thing to do anyway, and then language mismatch could be detected on paste.)

Yeah, if the <figcaption> had a lang attribute it'd be a lot easier for us, and we'd use that in preference if it were in the content language of the paste target.

Jdforrester-WMF lowered the priority of this task from High to Medium.Jan 9 2015, 10:55 PM
Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 12:23 PM