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: app/code/Magento/PageBuilder/docs/image-uploader.md
+19-2Lines changed: 19 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -107,10 +107,12 @@ Use `additional_data` in your `<YourModule>/view/base/pagebuilder/content_type/<
107
107
108
108
To update the `<YourModule>/view/adminhtml/web/js/content-type/<content_type_name>/preview.js` file:
109
109
110
-
1. Add the uploader component, 'Magento_PageBuilder/js/content-type/uploader', dependency:
110
+
1. Import the `Magento_PageBuilder/js/content-type/uploader` component as dependency.
111
+
112
+
For example:
111
113
112
114
```js
113
-
importUploaderfrom"../uploader";
115
+
define(['Magento_PageBuilder/js/content-type/uploader'], function (Uploader) {
114
116
```
115
117
116
118
**Constructor arguments**
@@ -125,6 +127,21 @@ import Uploader from "../uploader";
125
127
| `onChangeCallback` | Function | A callback that will be called when an image is selected. | false | The image will be saved to the provided `dataStore` using `uploaderConfig.dataScope` as the key. |
126
128
| `onDeleteCallback` | Function | A callback that will be called when the current used image is deleted from storage. | false | The image will be removed from to the provided `dataStore` using `uploaderConfig.dataScope` as the key. |
127
129
130
+
An example extracted from the image content type:
131
+
132
+
```js
133
+
var dataStore =this.parent.dataStore.get();
134
+
var initialImageValue = dataStore[this.config.additional_data.uploaderConfig.dataScope] ||"";
135
+
136
+
this.uploader=newUploader(
137
+
'imageuploader_'+this.parent.id,
138
+
this.config.additional_data.uploaderConfig,
139
+
this.parent.id,
140
+
this.parent.dataStore,
141
+
initialImageValue,
142
+
);
143
+
```
144
+
128
145
2. Add configuration for the uploader in the `<content-type-name>.xml` file to initialize the uploader.
129
146
130
147
3. Register the listener to specify when the image is loaded from the uploader UI component:
0 commit comments