query-b3f7610c2051b8ab5aefe698806b6d5b
External links from Commons File:pagesThanks to Lucas Werkmeister again
Use at
- https://query.wikidata.org/sparql
PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?image ?extlink WHERE {
wd:Q4656096 wdt:P18 ?image.
BIND(STRAFTER(STR(?image), "FilePath/") AS ?encoded_name)
BIND(wikibase:decodeUri(?encoded_name) AS ?name)
OPTIONAL { SERVICE wikibase:mwapi { # External links from each image
bd:serviceParam wikibase:api "Generator";
wikibase:endpoint "commons.wikimedia.org";
mwapi:generator "allimages";
mwapi:gaifrom ?name;
mwapi:gaito ?name;
mwapi:prop "extlinks";
mwapi:ellimit "500".
?extlink wikibase:apiOutput "extlinks/el/text()".
} }
} ORDER BY ?name
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?encoded_name")
v4("?extlink"):::projected
v2("?image"):::projected
v4("?name")
c18(["extlinks/el/text()"]):::literal
c14(["extlinks"]):::literal
c10(["allimages"]):::literal
c4(["bd:serviceParam"]):::iri
c16(["500"]):::literal
c1(["wd:Q4656096"]):::iri
c8(["commons.wikimedia.org"]):::literal
c6(["Generator"]):::literal
c1 --"wdt:P18"--> v2
bind0[/"substring-after(str(?image),'FilePath/')"/]
v2 --o bind0
bind0 --as--o v3
bind1[/"http://wikiba.se/ontology#decodeUri(?encoded_name)"/]
v3 --o bind1
bind1 --as--o v4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
subgraph s1["http://wikiba.se/ontology#mwapi"]
style s1 stroke-width:4px;
c4 -."mwapi:api".-> c6
c4 --"mwapi:endpoint"--> c8
c4 --"mwapi:generator"--> c10
c4 --"mwapi:gaifrom"--> v4
c4 --"mwapi:gaito"--> v4
c4 --"mwapi:prop"--> c14
c4 --"mwapi:ellimit"--> c16
v4 --"mwapi:apiOutput"--> c18
end
end