Page MenuHomePhabricator

Parser::maybeMakeExternalImage uses hardcoded regex to link external images - it doesn't support e.g webp, ico and svg
Closed, DuplicatePublic

Description

As an editor i would like to hotlink external images like webp, ico and svg. Now this formats are not parsed as an image.

As a company that uses MediaWiki, we would like to hotlink images that don't match regex specified in Parser::EXT_IMAGE_REGEX without making changes in MW Core.
Example image links:

Our propositions:

Event Timeline

Change 664776 had a related patch set uploaded (by Aklapper; owner: Mnowicka):
[mediawiki/core@master] includes/parser: Modify EXT_IMAGE_REGEX

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

Change 663183 had a related patch set uploaded (by Aklapper; owner: Mnowicka):
[mediawiki/core@master] includes/parser: Use a new configuration variable

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

Change 661376 had a related patch set uploaded (by Aklapper; owner: Mnowicka):
[mediawiki/core@REL1_33] includes/parser: Add a new hook

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

Change 661376 abandoned by Umherirrender:

[mediawiki/core@REL1_33] includes/parser: Add a new hook

Reason:

This release is EOL

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

Hm. $wgAllowExternalImagesFrom is a configuration which MediaWiki will almost certainly never use in production, and having to extend it ad hoc to support query parameters (which ones) and arbitrary filename suffixes seems pretty fragile.

I think I'd prefer to rip out the entire "allow external images" feature entirely and just replace it with a hook in the external link parser. Once we've parsed the external link (which can include query parameters I believe) we'll just give it to the "is this an allowed external image" hook. If it returns true, we'll render it as an external image. MediaWiki will never attach anything to the hook, and we can rip out all the code having to do with maintaining allowed-domain lists and move it to a community-supported extension.

There's a start at this in https://gerrit.wikimedia.org/r/c/mediawiki/core/+/604496