Updated Commons DAM example to work - User-agent is missing - #3028
Conversation
| <div> | ||
| <a href="{{ asset.assetMetadata.page_url }}">Image</a> | ||
| {% if asset.assetMetadata.author %} by {{ asset.assetMetadata.author }}{% endif %} | ||
| {% if asset.assetMetadata.author %} by {{ asset.assetMetadata.author|striptags }}{% endif %} |
There was a problem hiding this comment.
If we trust that the URL coming from Commons cannot contain bad things. This will display the author as link:
| {% if asset.assetMetadata.author %} by {{ asset.assetMetadata.author|striptags }}{% endif %} | |
| {% if asset.assetMetadata.author %} by {{ asset.assetMetadata.author|raw }}{% endif %} |
There was a problem hiding this comment.
It's a 3rd party site so we can never be 100% sure - and this template is just an example, this will be easy to modify.
I'd keep it as it (striptags instead of raw), better safe than sorry
There was a problem hiding this comment.
https://commons.wikimedia.org/wiki/Commons:Reusing_content_outside_Wikimedia and https://commons.wikimedia.org/wiki/Commons:Credit_line#Credit_lines_required_by_license doesn't seem to specifically require a link on the author, I guess the link to the image page is enough. To strip the author link shouldn't be an legal issue. In short, I'm OK with this change.
|
|
||
| class WikimediaCommonsHandler implements HandlerInterface | ||
| { | ||
| private const USER_AGENT = 'Ibexa DXP Commons Dam Connector'; |
There was a problem hiding this comment.
Maybe you want to inject Product name somehow . Wasn't sure if that worked in code snippets so hardcoded "Ibexa DXP"...
|
Preview of modified files: no change to preview. |
| <div> | ||
| <a href="{{ asset.assetMetadata.page_url }}">Image</a> | ||
| {% if asset.assetMetadata.author %} by {{ asset.assetMetadata.author }}{% endif %} | ||
| {% if asset.assetMetadata.author %} by {{ asset.assetMetadata.author|striptags }}{% endif %} |
There was a problem hiding this comment.
It's a 3rd party site so we can never be 100% sure - and this template is just an example, this will be easy to modify.
I'd keep it as it (striptags instead of raw), better safe than sorry
code_samples/ change report
|
* Added user-agent header in requests to Commons DAM * Fixed author line in view template for Commons DAM * PHP & JS CS Fixes --------- Co-authored-by: vidarl <vidarl@users.noreply.github.com>
An
User-Agentheader is required, or Commons will only reply with 403 access denied now.Also, small improvement to view template:

vs
Checklist