Topic on Project:Support desk

Comma Instead of Period in SRCSET Breaks IMG Tag

5
Summary by Ciencia Al Poder
Chris2fr (talkcontribs)

Hi,

The main image link on the file page in my setup has a "1,5x," in the srcset attribute of the img tag. It should be "1.5x," instead. Because of this, none of my files are showing correctly in the "File:..." pages nor as thumbs in the Wiki pages. The thumb does work correctly in the "File:" page as do links to other image resolutions.

The following test page describes the problem:

http://en.wiki.mann.fr/testimg.html

In the example, the image on

http://en.wiki.mann.fr/index.php?title=File:MANN2098.jpg

has the following dysfunctional img tag

<img alt="File:MANN2098.jpg" src="/images/thumb/3/37/MANN2098.jpg/400px-MANN2098.jpg" width="400" height="600" srcset="/images/thumb/3/37/MANN2098.jpg/600px-MANN2098.jpg 1,5x, /images/thumb/3/37/MANN2098.jpg/800px-MANN2098.jpg 2x">

Whereas if I change "1,5x," to "1.5x,", it works perfectly well, as is to be expected.

<img alt="File:MANN2098.jpg" src="/images/thumb/3/37/MANN2098.jpg/400px-MANN2098.jpg" width="400" height="600" srcset="/images/thumb/3/37/MANN2098.jpg/600px-MANN2098.jpg 1.5x, /images/thumb/3/37/MANN2098.jpg/800px-MANN2098.jpg 2x">

It seems like a bug to me.

In France, where I am physically, but not the language neither of the Wiki nor of the server, the decimal point is a comma. I do not think that pertains to my current problem.

Many thanks,

Chris

Chris2fr (talkcontribs)

I replaced

$candidates[$density] = $url . ' ' . $density . 'x';

with

$candidates[$density] = $url . ' ' .  str_replace(",",".",(string)$density) . 'x';

in

includes/Html.php

It works, but it is a hack.

Ciencia Al Poder (talkcontribs)

It's a bug, clearly. You may want to add this to LocalSettings.php to force an invariant locale for numeric conversions:

setlocale(LC_NUMERIC, "C")
Ciencia Al Poder (talkcontribs)
TheDJ (talkcontribs)

I guess you have a non-C locale for your php setup...

I've created phab:T183660