feat: folder selection support in useMediaAsset and file widget (#706)
This commit is contained in:
@ -372,7 +372,7 @@ const validator = () => {
|
||||
|
||||
If you want to use the media library in your custom widget you will need to use the `useMediaInsert` and `useMediaAsset` hooks.
|
||||
|
||||
- `useMediaInsert` - Takes the current url to your media, details about your field (including a unique ID) and a callback method for when new media is uploaded.
|
||||
- `useMediaInsert` - Takes the current url to your media, details about your field (including a unique ID) and a callback method for when new media is uploaded. If you want to select folders instead of files, set the `forFolder` variable in options.
|
||||
- `useMediaAsset` - Transforms your stored url into a usable url for displaying as a preview.
|
||||
|
||||
<CodeTabs>
|
||||
|
@ -14,15 +14,16 @@ The file widget allows editors to upload a file or select an existing one from t
|
||||
|
||||
For common options, see [Common widget options](/docs/widgets#common-widget-options).
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
| ------------- | --------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| default | string | `null` | _Optional_. The default value for the field. Accepts a string. |
|
||||
| media_folder | string | | _Optional_. Specifies the folder path where uploaded files should be saved, relative to the base of the repo |
|
||||
| public_folder | string | | _Optional_. Specifies the folder path where the files uploaded by the media library will be accessed, relative to the base of the built site |
|
||||
| media_library | Media Library Options | `{}` | _Optional_. Media library settings to apply when the media library is opened by the current widget. See [Media Library](/docs/configuration-options#media-library) |
|
||||
| choose_url | boolean | `false` | _Optional_. When set to `false`, the "Insert from URL" button will be hidden |
|
||||
| Name | Type | Default | Description |
|
||||
| ------------- | --------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| default | string | `null` | _Optional_. The default value for the field. Accepts a string. |
|
||||
| media_folder | string | | _Optional_. Specifies the folder path where uploaded files should be saved, relative to the base of the repo |
|
||||
| public_folder | string | | _Optional_. Specifies the folder path where the files uploaded by the media library will be accessed, relative to the base of the built site |
|
||||
| media_library | Media Library Options | `{}` | _Optional_. Media library settings to apply when the media library is opened by the current widget. See [Media Library](/docs/configuration-options#media-library) |
|
||||
| choose_url | boolean | `false` | _Optional_. When set to `false`, the "Insert from URL" button will be hidden |
|
||||
| select_folder | boolean | `false` | _Optional_. When set to `true`, selecting folders instead of files will be possible. See [Media Library](/docs/configuration-options#media-library) for folder support. |
|
||||
|
||||
## Example
|
||||
## Examples
|
||||
|
||||
<CodeTabs>
|
||||
```yaml
|
||||
@ -40,3 +41,20 @@ default: '/uploads/general-manual.pdf',
|
||||
```
|
||||
|
||||
</CodeTabs>
|
||||
|
||||
<CodeTabs>
|
||||
```yaml
|
||||
name: gallery_folder
|
||||
label: Gallery Folder
|
||||
widget: file
|
||||
select_folder: true
|
||||
```
|
||||
|
||||
```js
|
||||
name: 'gallery_folder',
|
||||
label: 'Gallery Folder',
|
||||
widget: 'file',
|
||||
select_folder: true,
|
||||
```
|
||||
|
||||
</CodeTabs>
|
||||
|
@ -218,7 +218,7 @@ CMS.registerShortcode<YouTubeShortcodeProps>('youtube', {
|
||||
|
||||
If you want to use the media library in your shortcode you will need to use the `useMediaInsert` and `useMediaAsset` hooks.
|
||||
|
||||
- `useMediaInsert` - Takes the current url to your media, details about your field and a callback method for when new media is uploaded.
|
||||
- `useMediaInsert` - Takes the current url to your media, details about your field and a callback method for when new media is uploaded. If you want to select folders instead of files, set the `forFolder`variable in options.
|
||||
- `useMediaAsset` - Transforms your stored url into a usable url for displaying as a preview.
|
||||
|
||||
<CodeTabs>
|
||||
|
Reference in New Issue
Block a user