Skip to content

Commit 0093a5e

Browse files
committed
MAGEDOC-3432: Clarify image uploader topic
Updated docs
1 parent 7fc00f8 commit 0093a5e

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

docs/how-to/how-to-use-image-uploader.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# How to add the Image Uploader
1+
# How to add an image uploader
22

3-
This topic describes how to add the image Uploader component to your content type. Find the source code for the Uploader here: `app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/uploader.ts`).
3+
This topic describes how to add the image uploader component to your content type so that end-users can add images to a page.
44

55
![How to add an image uploader](../images/how-to-add-image-uploader.svg)
66

7-
## Step 1: Add configuration data for the Uploader
7+
## Step 1: Add configuration data for the uploader
88

9-
Use the `additional_data` element in your content type's config file to add a custom configuration for the image Uploader:
9+
The first step is to customize the image uploader to suit your needs. To do this, you must add the `additional_data` element to your content type's config file, then use the `item` elements to create the data types and values to initialize the image uploader to meet your specific needs.
1010

1111
``` xml
1212
<?xml version="1.0"?>
@@ -43,9 +43,17 @@ Use the `additional_data` element in your content type's config file to add a cu
4343
</config>
4444
```
4545

46-
## Step 2: Create an instance of the Uploader
46+
The Page Builder image uploader provides a wrapper around the Magento [ImageUploader component](https://devdocs.magento.com/guides/v2.3/ui_comp_guide/components/image-uploader/), which extends the Magento [FileUploader component](https://devdocs.magento.com/guides/v2.3/ui_comp_guide/components/ui-fileuploader.html). The documentation at those links describes most of the configuration properties. You can find the other properties (shown in the `additional_data` entries above) within these source files:
47+
- `magento2-page-builder/app/code/Magento/PageBuilder/view/adminhtml/web/js/form/element/image-uploader.js`
48+
- `magento2-page-builder/app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/uploader.ts`
4749

48-
To create an instance of the image uploader in your preview component (`preview.js`), import the `Magento_PageBuilder/js/content-type/uploader` component as a dependency and call the Uploader constructor, passing in your content type's configuration options (added in step 1) and the other required arguments, as shown here :
50+
51+
**[Are these all the settings? Which of these settings is required?]**
52+
53+
54+
## Step 2: Create an instance of the uploader
55+
56+
To create an instance of the image uploader in your preview component (`preview.js`), import the `Magento_PageBuilder/js/content-type/uploader` component as a dependency and call the uploader constructor, passing in your content type's configuration options (added in step 1) and the other required arguments, as shown here :
4957

5058
``` js
5159
define(['Magento_PageBuilder/js/content-type/uploader'], function (Uploader) {
@@ -64,22 +72,22 @@ define(['Magento_PageBuilder/js/content-type/uploader'], function (Uploader) {
6472
};
6573
```
6674
67-
### Uploader constructor arguments
75+
**Uploader constructor arguments**
6876
6977
7078
| Argument | Type | Description | Required | Default |
7179
| ------------------ | --------- | ----------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------- |
7280
| `name` | String | Used to locate the component in the UI registry. | yes | None |
7381
| `uploaderConfig` | Object | Initializes the image uploader UI component with the configuration settings from the `additional_data` element. | yes | None |
74-
| `contentTypeId` | String | The ID of the content type you are adding the Uploader to. | yes | None |
82+
| `contentTypeId` | String | The ID of the content type you are adding the uploader to. | yes | None |
7583
| `dataStore` | DataStore | The DataStore to store the selected image in. | yes | None |
76-
| `initialValue` | Object[] | The image value to set for the initial state of the Uploader component. | yes | None |
84+
| `initialValue` | Object[] | The image value to set for the initial state of the uploader component. | yes | None |
7785
| `onChangeCallback` | Function | The callback to execute when the end-user selects an image. | no | Magento saves the image to the provided `dataStore` using `uploaderConfig.dataScope` as the key. |
7886
| `onDeleteCallback` | Function | The callback to execute when the end-user deletes the current image from storage. | no | Magento removes the image from to the provided `dataStore` using `uploaderConfig.dataScope` as the key. |
7987
80-
## Step 3: Add markup for the Uploader
88+
## Step 3: Add markup for the uploader
8189
82-
To add the image Uploader to your preview template (`preview.html`), use Knockout's `scope` binding element to render an instance of your configured Uploader component from the Magento registry, as shown here:
90+
To add the image uploader to your preview template (`preview.html`), use Knockout's `scope` binding element to render an instance of your configured uploader component from the Magento registry, as shown here:
8391
8492
``` html
8593
<div ...>
@@ -91,6 +99,5 @@ To add the image Uploader to your preview template (`preview.html`), use Knockou
9199
</div>
92100
```
93101
94-
95102
{: .bs-callout .bs-callout-info }
96-
When an end-user deletes a file from the media browser, Magento triggers the `fileDeleted` event on the window with the `mediabrowser` namespace. The passed argument is an object containing the `ids` property, which is an array of ID strings for each of the deleted files. Magento adds the IDs of the selected files in the objects dispatched by the `addFile` and `processFile` methods inside the image Uploader component.
103+
When an end-user deletes a file from the media browser, Magento triggers the `fileDeleted` event on the window with the `mediabrowser` namespace. The passed argument is an object containing the `ids` property, which is an array of ID strings for each of the deleted files. Magento adds the IDs of the selected files in the objects dispatched by the `addFile` and `processFile` methods inside the image uploader component.

0 commit comments

Comments
 (0)