Page MenuHomePhabricator

API categorymembers cmprop to include date image taken
Open, Needs TriagePublicFeature


I want to return a list of images in a category with the date the image was taken, to put historical images in a timeline. Currently only has cmprop=timestamp, the date the image was added to mediawiki, rather than when it was originally taken (or painted etc), which is often recorded in the Date file for the items. Currently I would need to extract filenames and do requests for each one with query and pageprops to extract the date.

This would allow timelines of how a location has changed over time, how an artist's style develops, etc

Event Timeline

Looking into this more, it looks like Date is a wooly free format text that is only accessible by the hugely verbose

The structured data fields inception (P581) or point in time (P585) would be better if a) people populated it, b) there was an API to extract structured data. Is there one?

I found the wikimedia SPARQL service, and came up with

SELECT DISTINCT ?item ?image ?date ?label ?qualityLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
    SELECT DISTINCT ?item ?date ?image
      (COALESCE(?label1,?label2) AS ?label)
      (SAMPLE(?quality1) AS ?quality) WHERE {
      ?item wdt:P180 wd:Q757178. # HMS Belfast      
      OPTIONAL {?item rdfs:label ?label1}
      ?item schema:url ?url.
      BIND (wikibase:decodeUri(substr(str(?url),52)) AS ?image)
      BIND (REPLACE(?image,".jpg","") AS ?label2)
      OPTIONAL {?item wdt:P571 ?date}
      OPTIONAL {?item wdt:P6731 ?quality1.}
    GROUP BY ?item ?date ?image ?label1 ?label2
ORDER BY DESC(?quality) DESC(?label)

which does what I want with dates, and allows me to get the best images, so I am no longer seeking the feature here.

... cmprop=timestamp, the date the image was added to mediawiki

cmprop=timestamp actually gives the time at which the page was added to the category.