query-226a3a62cf8024a0d28ee54741539e6d
Salgo60mw:Manual:$wgHashedUploadDirectory
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX schema: <http://schema.org/>
SELECT DISTINCT ?item ?wdimage ?calculated_contentUrl ?calculated_contentUrl_is_verified ?wdimage_depicts_item
WHERE
{
{
SELECT ?item ?wdimage ?calculated_contentUrl
WHERE
{
SERVICE <https://query.wikidata.org/sparql>
{
?item wdt:P1261 ?signum .
?item wdt:P18 ?wdimage .
}
BIND (REPLACE(wikibase:decodeUri(SUBSTR(STR(?wdimage), 52)), " ", "_") AS ?filename)
BIND (REPLACE(SUBSTR(STR(?wdimage), 52), "%20", "_") AS ?filenameUnencoded)
BIND (MD5(?filename) AS ?MD5)
BIND (URI(CONCAT("https://upload.wikimedia.org/wikipedia/commons/",
SUBSTR(?MD5, 1, 1), "/", SUBSTR(?MD5, 1, 2), "/", ?filenameUnencoded)) As ?calculated_contentUrl)
}
} # Check if the calculated contentURL is in WCQS. If not it may be newer than the latest update.
OPTIONAL
{
?file schema:contentUrl ?calculated_contentUrl .
BIND (true AS ?calculated_contentUrl_is_verified)
}
# Check if ?wdimage depicts ?item
OPTIONAL
{
?file schema:contentUrl ?calculated_contentUrl .
?file wdt:P180 ?item .
BIND (true AS ?wdimage_depicts_item)
}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?MD5")
v7("?calculated_contentUrl"):::projected
v9("?calculated_contentUrl_is_verified"):::projected
v8("?file")
v4("?filename")
v5("?filenameUnencoded")
v1("?item"):::projected
v2("?signum")
v3("?wdimage"):::projected
v10("?wdimage_depicts_item"):::projected
subgraph s1["https://query.wikidata.org/sparql"]
style s1 stroke-width:4px;
v1 --"wdt:P1261"--> v2
v1 --"wdt:P18"--> v3
end
bind0[/"replace(http://wikiba.se/ontology#decodeUri(substring(str(?wdimage),'52^^xsd:integer')),' ','_')"/]
v3 --o bind0
bind0 --as--o v4
bind1[/"replace(substring(str(?wdimage),'52^^xsd:integer'),'%20','_')"/]
v3 --o bind1
bind1 --as--o v5
bind2[/"MD5(?filename)"/]
v4 --o bind2
bind2 --as--o v6
bind3[/"concat('https://upload.wikimedia.org/wikipedia/commons/',substring(?MD5,'1^^xsd:integer','1^^xsd:integer'),'/',substring(?MD5,'1^^xsd:integer','2^^xsd:integer'),'/',?filenameUnencoded)"/]
v6 --o bind3
v5 --o bind3
bind3 --as--o v7
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v8 -."schema:contentUrl".-> v7
bind4[/"'true^^xsd:boolean'"/]
bind4 --as--o v9
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v8 -."schema:contentUrl".-> v7
v8 --"wdt:P180"--> v1
bind5[/"'true^^xsd:boolean'"/]
bind5 --as--o v10
end