Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tag image with a value File: #9723

Open
Mahabarata opened this issue Jul 2, 2023 · 1 comment
Open

tag image with a value File: #9723

Mahabarata opened this issue Jul 2, 2023 · 1 comment

Comments

@Mahabarata
Copy link

Description

Hi,

A few days ago, I removed the tag image because the link "File:nnn.jpg" didn't work on iD : on the left, I expanded the Field, clicked on the arrow next to the value of the image tag and nothing happened.

Then some days later, I found many other similar cases so I looked at the wiki and see that image=File:... is a simple syntax of wikimedia_commons tag : https://wiki.openstreetmap.org/wiki/Key:image

I feel terribly sorry for my change, I don't remember on which element I made this so I cannot restore the image.

The wiki page tells us that image is not a good tag for many reasons. Except in one case : when the value is "File:...".

According to overpass https://overpass-turbo.eu/s/1wSe, there are more than 24000 elements with these tags/links.

Could you improve the link when the value is "File:..." by automatically adding "https://commons.wikimedia.org/wiki/" like with the tag wikimedia_commons ?

Best regards

Screenshots

No response

@1ec5
Copy link
Collaborator

1ec5 commented Nov 6, 2023

Could you improve the link when the value is "File:..." by automatically adding "https://commons.wikimedia.org/wiki/" like with the tag wikimedia_commons ?

As far as I know, setting image to a Wikimedia Commons page name is a tagging error; it always has to be a URL. Otherwise, iD can’t know that the page is in the File: namespace of Wikimedia Commons versus another MediaWiki-powered wiki, such as the English Wikipedia, French Wikivoyage, or WegenWiki.

That said, iD should indicate when the field’s valid is malformed. To accomplish that, this field JSON should include a pattern property set to a regular expression that every value should match. The regular expression would look something like ^https?://.1 That change should be tracked in the id-tagging-schema repository rather than this repository.

I don’t think it would be necessary to perform full URL validation in order to avoid the mistakes you found, but that could happen in this function, by trying to initialize a URL object and catching any exception:

function validIdentifierValueForLink() {
const value = utilGetSetValue(input).trim();
if (field.type === 'url' && value) {
try {
return (new URL(value)).href;
} catch (e) {
return null;
}
}
if (field.type === 'identifier' && field.pattern) {
return value && value.match(new RegExp(field.pattern))?.[0];
}
return null;
}

If the user attempts to enter a malformed value – one that doesn’t match the pattern – the field will be highlighted in red. That should be enough to prompt the user to either convert the value to a URL or move the value to the Wikimedia Commons Page field. As an additional step, we could implement a validator rule similar to the one for e-mail addresses, which results in a warning banner that counts against your How Did You Contribute permanent record if you ignore it. This validator warning can come with a button that moves the value to wikimedia_commons.

function isValidEmail(email) {
// Emails in OSM are going to be official so they should be pretty simple
// Using negated lists to better support all possible unicode characters (#6494)
var valid_email = /^[^\(\)\\,":;<>@\[\]]+@[^\(\)\\,":;<>@\[\]\.]+(?:\.[a-z0-9-]+)*$/i;
// An empty value is also acceptable
return (!email || valid_email.test(email));
}

However, before we take a step like that, the community first needs to reach a consensus about whether wikimedia_commons is preferable to image.

I feel terribly sorry for my change, I don't remember on which element I made this so I cannot restore the image.

I used OSMCha to find image tags that were removed towards the end of June and restored those file names, but in wikimedia_commons. The user who removed the tags has deleted their OSM account, so I won’t share more details, but you can search my OSM contributions if you want to verify that I fixed the features you touched.

Footnotes

  1. I’m unsure if any protocol besides HTTP and HTTPS would be considered valid. Currently, only 11 features set image to a URL that isn’t HTTP/HTTPS. Most are typos, but a couple are local file: URLs, which would technically be well-formed but nonexistent Wikimedia Commons page names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants