Hi Bastien,

Given an image file name, how do you programmatically
> retrieve the permalink?
>
> E.g. given Kohila_vesiveski2.jpg I can easily infer
> http://commons.wikimedia.org/wiki/File:Kohila_vesiveski2.jpg
> but not
>
>
> http://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Kohila_vesiveski2.jpg/320px-Kohila_vesiveski2.jpg
>
> Where does the "/2/24/" comes from?  (The rest of the URL seems
> to follow a regular pattern.)
>

On wiki, you may use [[Special:FilePath]]
<
https://commons.wikimedia.org/w/index.php?title=Special%3AFilePath&file=Kohila+vesiveski2.jpg&width=800
>

Using the API, I *think* imageinfo is what you are looking for (but there
might be a better way):
<
https://commons.wikimedia.org/wiki/Special:ApiSandbox#action=query&prop=imageinfo&format=json&iiprop=url&iilimit=1&titles=File%3AKohila_vesiveski2.jpg
>

Cheers,
-- 
Jean-Frédéric
_______________________________________________
Wiki Loves Monuments mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikilovesmonuments
http://www.wikilovesmonuments.org

Reply via email to