Page MenuHomePhabricator

External images should support SVG
Closed, ResolvedPublic

Description

We have a template which places .gif images like this

https://www.astro.com/im/sym/s_su.18.gif

In the HTML page rendering, it appears as

<img src="https://www.astro.com/im/sym/s_su.18.gif" alt="s_su.18.gif">

I would like to replace the .gif images with .svg images like this:

https://www.astro.com/im/sym/s_su.18.svg

but that is rendered into

<a class="external free" href="https://www.astro.com/im/sym/s_su.18.svg">https://www.astro.com/im/sym/s_su.18.svg</a>

@TheDJ told me that private const EXT_IMAGE_REGEX in Parser.php should be updated.
I patched it to read now

private const EXT_IMAGE_REGEX = '/^(http:\/\/|https:\/\/)((?:\\[(?i:[0-9a-f:.]+)\\])?[^][<>"\\x00-\\x20\\x7F\p{Zs}\x{FFFD}]+)
                \\/([A-Za-z0-9_.,~%\\-+&;#*?!=()@\\x80-\\xFF]+)\\.((?i)gif|png|jpg|jpeg|svg)$/Sxu';

Now links to of .svg images works.

I also need to update common.css and add

.infobox.toccolours tr td img {width: 18px;}

to get the svg glyphs in the right size.

Event Timeline

Pppery renamed this task from using .svg image in template to External images should support SVG.Wed, May 22, 5:47 PM
Pppery added a project: MediaWiki-Parser.
Pppery updated the task description. (Show Details)
Pppery added a subscriber: TheDJ.

One of you is welcome to submit that patch to Gerrit following the instructions at https://www.mediawiki.org/wiki/Gerrit/Tutorial

Change #1035038 had a related patch set uploaded (by TheDJ; author: TheDJ):

[mediawiki/core@master] Detect modern image formats when using wgAllowExternalImages

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

Change #1035837 had a related patch set uploaded (by TheDJ; author: TheDJ):

[mediawiki/services/parsoid@master] Detect modern image formats when using wgAllowExternalImages

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

Change #1035038 merged by jenkins-bot:

[mediawiki/core@master] Detect modern image formats when using wgAllowExternalImages

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

Change #1042374 had a related patch set uploaded (by TheDJ; author: TheDJ):

[mediawiki/core@master] Add release note for this feature

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

Change #1035837 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Detect modern image formats when using wgAllowExternalImages

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

Change #1042374 merged by jenkins-bot:

[mediawiki/core@master] Add release note for this feature

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

Change #1043324 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.20.0-a8

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

Change #1043324 merged by jenkins-bot:

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.20.0-a8

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