> For the complete documentation index, see [llms.txt](https://docs.scaleflex.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scaleflex.com/digital-asset-management-dam/plugins-and-connectors/plugins/directus.md).

# Directus

Scaleflex DAM x Directus extension

## Installation <a href="#od_1e92263f" id="od_1e92263f"></a>

### Prerequisites <a href="#od_117c69a2" id="od_117c69a2"></a>

* [Register for a demo](https://www.scaleflex.com/en/request-a-demo) if you don't already have a Scaleflex DAM account.
* Need to add a config CONTENT SECURITY POLICY to your **.env** file

```
CONTENT_SECURITY_POLICY_USE_DEFAULTS: true
CONTENT_SECURITY_POLICY_DIRECTIVES__SCRIPT_SRC: "'self','unsafe-eval',*.scaleflex.com,cdn.tiny.cloud"
CONTENT_SECURITY_POLICY_DIRECTIVES__IMG_SRC: "'self',data:,blob:,https://raw.githubusercontent.com,https://avatars.githubusercontent.com,*.filerobot.com,*.tinymce.com"
CONTENT_SECURITY_POLICY_DIRECTIVES__MEDIA_SRC: "'self', *.filerobot.com"
```

### Step 1: Install the extension via Marketplace or via NPM

**Marketplace:**

<figure><img src="https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2FYWQa78gyofpJKgqJYm12%2Fimage.png?alt=media&amp;token=b478e385-96fe-43bd-9739-118352de83ce" alt=""><figcaption></figcaption></figure>

**NPM Install:**

```
npm i @plugins_sfx/directus-extension-scaleflex-dam
```

### Step 2: Active the Scaleflex DAM extension

Click on **"Settings"** on the left menu and after that click **"Extensions"** on the sub-menu.

<figure><img src="https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2FXxesBJMZA51C7pr8J9ad%2Fimage.png?alt=media&amp;token=784c3ae7-c9fb-4e73-9477-b76bbb1f9756" alt=""><figcaption></figcaption></figure>

### Step 3: Show the extension on the left menu

Click **"Settings"** on the left menu and then click **"Settings"** on the sub-menu.

Scroll to block **Modules** and check two items **"Scaleflex DAM Settings"** and **"Scaleflex DAM"**

<figure><img src="https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2Fu3GOPE56mNug6qCITCc7%2Fimage.png?alt=media&amp;token=895343b1-b9ee-47d0-b386-c6d668b8ae80" alt=""><figcaption></figcaption></figure>

### Step 4: Fill in your configuration

<figure><img src="https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2FVCNj4WEt1105RGvKULW6%2F3.png?alt=media&amp;token=6acec0f8-c1f2-4663-81a9-591dd352f33e" alt=""><figcaption></figcaption></figure>

* **Token:** Enter your Scaleflex DAM token here (eg: abcdefgh).
* **Security Template:** To load the Scaleflex DAM Widget, you must create a Security Template in your Scaleflex DAM Hub.
* **Root directory:** The directory in your Scaleflex DAM account, where the files will be stored.
* **TinyMCE Key:** API key required for TinyMCE when using it with DAM, Here’s a guide on how to get the key: [How to get tinymce cloud up in less than 5 minute](https://www.tiny.cloud/blog/how-to-get-tinymce-cloud-up-in-less-than-5-minutes/)

**Advanced Configuration**

* **CNAME:** Enter the CNAME as configured in your Scaleflex DAM Hub interface, once validated and the SSL certificate accepted. (Or leave blank if none). **Note:** To use the CNAME, you need to add your domain to the environment variable `CONTENT_SECURITY_POLICY_DIRECTIVES__IMG_SRC` and `CONTENT_SECURITY_POLICY_DIRECTIVES__MEDIA_SRC` in your Directus instance.
  * **Example value**: assets.yourdomain.com
* **Limit:** The maximum number of files that can be added to a single field, default: 0 (unlimited).
* **Attributes:** Attribute from Scaleflex DAM asset that you want to include in the Client response.
* **Limit Type:** File types are limited when using the Widget.

## How to use the Scaleflex DAM field?

### 1. Field Interface

{% tabs %}
{% tab title="1. Field interface" %}
When create new field with DAM Assets please choose Scaleflex DAM

<figure><img src="https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2F347M54odJjYFoeTtPmaJ%2Fimage.png?alt=media&amp;token=c509fd0f-0f4a-40ed-828b-57f9c6c2200e" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="2. Configuration" %}
There are some configurations:

Please aware that these configuration will override default configuration in Setting Page.

| Config         | Explain                                                                                  | Example |
| -------------- | ---------------------------------------------------------------------------------------- | ------- |
| **Limit**      | The maximum number of files that can be added to a single field, default: 0 (unlimited). |         |
| **Attributes** | Attribute from Scaleflex DAM asset that you want to include in Client response.          |         |
| **Limit Type** | File types are limited when using Widget.                                                |         |
| {% endtab %}   |                                                                                          |         |

{% tab title="3. Display" %}

{% endtab %}
{% endtabs %}

**1/** Create a new field **"Scaleflex DAM"**

<figure><img src="https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2FZwCZZaV9cBOXhjVw7SZy%2Fimage.png?alt=media&amp;token=8cb74414-8a40-443a-8fb8-80ee59c28bca" alt=""><figcaption></figcaption></figure>

**2/** Select your display type

On the list fields, select the new field just created. On the tab **"Display"**, choose **"DAM Assets"**.

<figure><img src="https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2FG9rfXPkr8ositNO5Qneu%2Fimage.png?alt=media&amp;token=2504084c-f69a-4c40-b87d-91c91394023b" alt=""><figcaption></figcaption></figure>

**3/** Go to your content Model and you will see the new field just created. Click on **"Browse Assets"** to select the assets in **Scaleflex DAM**

<figure><img src="https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2Fy2Z6eKUllmbQPxyRVhIA%2Fimage.png?alt=media&amp;token=93e65a4c-1da5-43da-a15d-c5b36fbb8f82" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2FMUP9tgHp3Mh5EHtF4sgO%2Fimage.png?alt=media&amp;token=79314fc2-cd81-49a4-860c-73da2a57e884" alt=""><figcaption></figcaption></figure>

The result displayed after adding the assets

<figure><img src="https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2FrG8VTvwwwlsmX0GDpujf%2Fimage.png?alt=media&amp;token=aded378c-dd8d-4def-9cdb-fe89ded5e241" alt=""><figcaption></figcaption></figure>

You can modify the image by clicking on **"Show variants"** to resize or crop the image.

<div><figure><img src="https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2FXN5xjN46wsnCmmj1TqZ6%2Fimage.png?alt=media&amp;token=c11ba069-6ce3-477d-b4d7-78a705b86943" alt=""><figcaption></figcaption></figure> <figure><img src="https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2FkGbleTmjruMhHxAsBlXX%2Fimage.png?alt=media&amp;token=d0629737-1fc9-46de-b2f3-1f05ea15065d" alt=""><figcaption></figcaption></figure></div>

In the list of items

<figure><img src="https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2FoOl0wcyvSFGp0r7rRVlx%2Fimage.png?alt=media&amp;token=9fa9fc56-7d44-4ab4-8c93-1cba2c7b2364" alt=""><figcaption></figcaption></figure>

## Advanced Configuration Display

You can set the limit asset showing in the list of items.

In the **Field Settings**, click on the tab **"Display"** and choose **DAM Assets**. Input the limit items you want to show in the list.

<figure><img src="https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2FMJJoiTZ4KnzPq63B55FH%2Fimage.png?alt=media&amp;token=ffbeb3e8-990f-4e37-8205-de200d6966e0" alt=""><figcaption></figcaption></figure>

And the last thing, you can configure your variants asset in the tab **"Interface"**. For example:&#x20;

```
{
    "variants": [
        {
            "code": "desktop",
            "name": "Desktop",
            "preset": {
                "width": "200",
                "height": "400"
            }
        },
        {
            "code": "tablet",
            "name": "Tablet",
            "preset": {
                "width": "100",
                "height": "200"
            }
        }
    ]
}
```

## Using TinyMCE Editor with Scaleflex DAM

**1/** Create a new field **"WYSIWYG with Scaleflex DAM"**

<figure><img src="https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2FgNVUgMs4MT3agb8SdTHS%2Fimage.png?alt=media&amp;token=20e59b6c-5043-46b1-8f35-b3dcf69c2629" alt=""><figcaption></figcaption></figure>

**2/** Using the editor, click on the button "DAM" to add the asset to your content.

Support image, video, and audio.

<div><figure><img src="https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2Fn5buEJ6D4Ge3hoHH4bUD%2Fimage.png?alt=media&amp;token=fa49be41-503b-4e6e-8c31-6d8e895514fd" alt=""><figcaption></figcaption></figure> <figure><img src="https://2536208400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqsq2dR7Fjagf5eTifWZx%2Fuploads%2FPXKVLtqR7MS5MVAqtq4h%2Fimage.png?alt=media&amp;token=d5c24a06-fa49-4044-8251-fa144672dd71" alt=""><figcaption></figcaption></figure></div>
