Skip to content

Commit

Permalink
Add config instructions to allow specific file types (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
damsfx authored Mar 5, 2024
1 parent 180cbbb commit 7c37e8e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backend/forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ public function getStatusOptions($value, $formData)
// Insert the actual form's model value to avoid it to vanish
// on eventual AJAX call that would refresh the field partial like dependsOn
if ($this->status) {
// The actual form's status could be a custom like ['status' => 'need review']
$statuses->add(['status' => $this->status]);
}
Expand Down Expand Up @@ -876,6 +876,9 @@ Option | Description

> **NOTE:** Unlike the [Media Finder FormWidget](#media-finder), the File Upload FormWidget uses [database file attachments](../database/attachments); so the field name must match a valid `attachOne` or `attachMany` relationship on the Model associated with the Form. **IMPORTANT:** Having a database column with the name used by this field type (i.e. a database column with the name of an existing `attachOne` or `attachMany` relationship) **will** cause this FormWidget to break. Use database columns with the Media Finder FormWidget and file attachment relationships with the File Upload FormWidget.

By default, the File Upload FormWidget only allows a limited set of file extensions. You can extend this list by adding a `fileDefinitions` config in `config/cms.php` file.
See [Allowed file types](../setup/configuration#allowed-file-types) for more information.

### Icon Picker

`iconpicker` - renders an icon picker that is by default powered by the Font Awesome icons included by WinterCMS.
Expand Down
5 changes: 5 additions & 0 deletions cms/mediamanager.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ Parameter | Value
`videoExtensions` | file extensions corresponding to the Video document type. The default value is `['mp4', 'avi', 'mov', 'mpg']`.
`audioExtensions` | file extensions corresponding to the Audio document type. The default value is `['mp3', 'wav', 'wma', 'm4a']`.

### Allowing more specific file extensions

By default, the Media Manager only allows a limited set of file extensions. You can extend this list by adding a `fileDefinitions` config in `config/cms.php` file.
See [Allowed file types](../setup/configuration#allowed-file-types) for more information.

## Events

The Media Manager provides a few [events](../events/introduction) that you can listen for in order to improve extensibility.
Expand Down
23 changes: 23 additions & 0 deletions setup/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,29 @@ The `trustedProxyHeaders` value specifies which headers will be allowed to defin
> 'trustedProxyHeaders' => Illuminate\Http\Request::HEADER_X_FORWARDED_AWS_ELB
> ```
### Allowed file types
Winter CMS is preset to allow only certain file types in the media manager and file upload form widgets (see: `WinterStorm\Filesystem\Definitions`), but you can configure them to suit your needs by adding a `fileDefinitions` configuration value to your `config/cms.php` file.
File types are grouped into five categories:
- defaultExtensions: Extensions that are particularly benign.
- assetExtensions: Extensions seen as public assets.
- imageExtensions: Extensions typically used as images.
- videoExtensions: Extensions typically used as videos.
- audioExtensions: Extensions typically used as audios.
The following example shows how to extend the default extensions group to add the `fig` and `jam` file extensions.
```php
'fileDefinitions' => [
'defaultExtensions' => array_merge(
\Winter\Storm\Filesystem\Definitions::get('defaultExtensions'),
['fig', 'jam']
),
]
```
## Environment configuration

### Defining a base environment
Expand Down

0 comments on commit 7c37e8e

Please sign in to comment.