Use css width for img custom width

The width attribute is the intrinsic width of the image, and thus
it will not overwrite the default CSS

cf https://forum.openstreetmap.fr/t/bugs-divers-relevees-sur-une-umap-absent-sur-une-autre/17254/5
This commit is contained in:
Yohan Boniface 2023-09-07 07:16:55 +02:00
parent d8b63974f9
commit 4857d7c29c
2 changed files with 2 additions and 2 deletions

View file

@ -129,7 +129,7 @@ L.Util.toHTML = (r, options) => {
// images
r = r.replace(/{{([^\]|]*?)}}/g, '<img src="$1">')
r = r.replace(/{{([^|]*?)\|(\d*?)}}/g, '<img src="$1" width="$2">')
r = r.replace(/{{([^|]*?)\|(\d*?)(px)?}}/g, '<img src="$1" style="width:$2px;min-width:$2px;">')
//Unescape http
r = r.replace(/(h_t_t_p)/g, 'http')

View file

@ -108,7 +108,7 @@ describe('L.Util', function () {
it('should handle image with width', function () {
assert.equal(
L.Util.toHTML('A simple image: {{http://osm.org/pouet.png|100}}'),
'A simple image: <img width="100" src="http://osm.org/pouet.png">'
'A simple image: <img style="width:100px;min-width:100px;" src="http://osm.org/pouet.png">'
)
})