You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: code_samples/back_office/images/src/Connector/Dam/Transformation/WikimediaCommonsTransformationFactory.php
Copy file name to clipboardExpand all lines: docs/content_management/images/add_image_asset_from_dam.md
+8-25Lines changed: 8 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,36 +86,20 @@ For more information about block customization (defined templates, variations),
86
86
87
87
## Extend DAM support by adding custom connector
88
88
89
-
To extend the DAM support built into [= product_name =], you must create a custom Symfony bundle.
89
+
To extend the DAM support built into [= product_name =], you must create a custom handler and transformation factory.
90
90
91
91
!!! note "Wikimedia Commons licensing"
92
92
93
93
Before you use Wikimedia Commons assets in a production environment, ensure that you comply with their [license requirements](https://commons.wikimedia.org/wiki/Commons:Reusing_content_outside_Wikimedia#How_to_comply_with_a_file's_license_requirements).
94
94
95
-
### Create bundle structure
96
-
97
-
In your project's `src` directory, create a folder for the new bundle, for example, `WikimediaCommonsConnector`.
98
-
99
-
In that folder, create the main class file `WikimediaCommonsConnector.php` for the bundle:
This class handles searching through Wikimedia Commons for images and fetching assets.
114
98
115
-
In `src\WikimediaCommonsConnector\Handler` folder, create the `WikimediaHandler.php` file that resembles the following example, which uses `search()` and `fetchAsset()` functions to query the server for images and return asset objects, respectively:
99
+
In `src\Connector\Dam\Handler` folder, create the `WikimediaCommonsHandler.php` file that resembles the following example, which uses `search()` and `fetchAsset()` functions to query the server for images and return asset objects, respectively:
Then register the transformation factory as a service:
@@ -145,7 +128,7 @@ Then register the transformation factory as a service:
145
128
### Register variations generator
146
129
147
130
The variation generator applies map parameters coming from the transformation factory to build a fetch request to the DAM.
148
-
The `WikimediaCommonsConnector` uses the built-in `URLBasedVariationGenerator` class, which adds all the map elements as query parameters of the request.
131
+
The solution uses the built-in `URLBasedVariationGenerator` class, which adds all the map elements as query parameters of the request.
149
132
150
133
For example, the handler generates the following URL with `new AssetUri()`:
151
134
@@ -168,13 +151,13 @@ The template deffines how images that come from Wikimedia Commons appear in the
168
151
In `templates/bundles/WikimediaCommonsConnector/`, add the `commons_asset_view.html.twig` file that resembles the following example:
0 commit comments