Module talk:WikidataIB/Archive 7: Difference between revisions

Content deleted Content added
m Archiving 1 discussion(s) from Module talk:WikidataIB) (bot
m Archiving 1 discussion(s) from Module talk:WikidataIB) (bot
Line 246:
::: where {{para|website}} is a local parameter that will override fetching from Wikidata. The template {{tl|wdib}} is just a convenience wrapper for <code><nowiki>{{#invoke:WikidataIB |getValue}}</nowiki></code> --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 17:39, 24 September 2020 (UTC)
::::Thanks - that's working well now &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 13:43, 25 September 2020 (UTC)
 
== Caption ==
 
What is the easiest way to retrieve the {{Q|P2096}} (caption) of an image? This should be a qualifier of {{Q|P18}}. Thanks &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 08:26, 30 September 2020 (UTC)
: {{re|MSGJ|label=Martin}} it's relatively straightforward to use getValue from WikidataIB to return just a qualifier:
: For {{q|Q83125}}
:* <code><nowiki>{{wdib |fwd=ALL |osd=n |P18 |qual=P2096 |qualsonly=y |qid=Q83125}}</nowiki></code> → {{wdib |fwd=ALL |osd=n |P18 |qual=P2096 |qualsonly=y |qid=Q83125}}
: The only complication is that the {{q|P2096}} is monolingual text, so there may be versions in other languages. The code should recognise the site language, so you should get the English version automatically.
: The only problem might occur if there is a media legend in another language, but not one in English. If you get something like this:
:* {{wdib |fwd=ALL |osd=n |P18 |qual=P2096 |qualsonly=y |qid=Q83125 |lang=fr}}
: you'll need to decide on whether to keep the code unchanged, but then follow the pen icon link to Wikidata and add a media legend in English; or to explicitly specify the language in the call (but then you should get nothing if there's no English version on Wikidata):
:* <code><nowiki>{{wdib |fwd=ALL |osd=n |P18 |qual=P2096 |qualsonly=y |lang=en |qid=Q83125}}</nowiki></code> → {{wdib |fwd=ALL |osd=n |P18 |qual=P2096 |qualsonly=y |lang=en |qid=Q83125}}
: Obviously you use <code><nowiki>|qid={{{qid|}}}</nowiki></code> in the actual template. Sorry it wasn't quite as short an answer as I would have wished. Cheers --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 12:30, 30 September 2020 (UTC)
::That's great, it's always better to have the long answer! The only issue I can think of, is if an image is supplied locally but without a caption. Then a caption may be taken from an image on wikidata but it would then be incorrect. Or what if two images are on wikidata, how would it choose between the captions? &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 13:44, 30 September 2020 (UTC)
::: I think {{u|Mike Peel}} wrestled with those problems and might be able to relate his experiences.
::: I think the solution to the locally supplied image is to wrap the wikidata call for the caption in something like <code><nowiki>{{#if:{{{image|}}} |{{caption|}} |{{wdib |fwd=ALL |osd=n |P18 |qual=P2096 |qualsonly=y |qid={{{qid|}}} }}</nowiki></code> which would only use a locally supplied caption with a locally supplied image.
::: There's a constraint on Wikidata that {{q|P18}} should have a single-value, but it does get ignored. You should always limit the number of images returned by setting {{para|maxvals|1}} if you're using the usual image syntax. That will return the first image and the first media legend, so it should avoid the potential for having a caption not associated with the image (probably!). --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 20:40, 30 September 2020 (UTC)