Cloudinary

The Cloudinary custom field extensions allows you to fetch data(videos and images) from Cloudinary and display them into a field of your Content type. Thus, while creating entries, you can select one or more images or videos as the input value for the field.

This step-by-step guide explains how to create a Cloudinary custom field extension for your content types in Contentstack. The steps performed are as follows:

  1. Create a Cloudinary account
  2. Add the Cloudinary custom field extension to your stack
  3. Use your custom field

Prerequisites

  1. Create a Cloudinary Account

    To use this extension, you need to create an account in Cloudinary. To do that, perform the following steps:

    1. Go to https://cloudinary.com/ and create a new account.
    2. After creating an account and logging in, go to the Dashboard. Here you will get details such as Cloud name, API key, API Secret, and Environment variable. Cloudinary Dashboard.png

    These details will be required when we set up our extension, so make a note of these. Now, let's move ahead and set up our extension.

  2. Add the Cloudinary Custom Field Extension to your Stack

    To add this extension to your stack, perform the following steps:

    1. Go to your stack, navigate to the “Settings” gear icon, and select Extensions.
    2. On the Extensions page, click on the + Add Extension button, and select Create new. If you have not added any extensions in the stack yet, click on the create a new one link as shown below.create-new-button.png
    3. In the Select Extension Type window, select Custom Field.select-custom-field.png
    4. On the Create New Extension page, enter values in the fields as given below:
      1. Title (required): Provide a suitable title, for example “Cloudinary,” for your custom field. This title will be visible when you select the extension in the custom field in your content type.
      2. Field data type (required): Select the data type in which the input data of the field should be saved in Contentstack. In this case, select JSON.
      3. Multiple (optional): Leave this field unchecked.
      4. Hosting method (required): Select Hosted by Contentstack as the hosting method for this content type.
      5. Extension Source Code (required): Specify the extension code here. To get the code, contact our Support team. The support team will provide you with the source code (src file). Copy the code from the index.html file located in the root folder and paste it in the Extension source code field.

        In the downloaded code inside the source folder, there's a cloudinary-widget HTML file. Upload this file as an asset in Contentstack as discussed here. After uploading the file, you'll get a URL in the asset details section, make note of this URL.
      6. Config Parameter (required): Enter the following configuration details as the extension's config parameter:
        {
            "widgetUrl": "<Widget URL>",
            "cloudName": "<Cloud_Name>",
            "apiKey": "<Cloudinary_API_Key"
        }
        The value for widgetURL is the URL of the cloudinary-widget HTML file which you just uploaded as an asset. The values for cloudName and apiKey can be retrieved from the Cloudinary dashboard as shown above. Configuration Page.png
    5. Save the custom field.

    Now, let’s understand how you can start using this custom field in your content type.

  3. Use Your Custom Field

    Once you have added a custom field, you can use it in your content type like any other field. To add a custom field in your content type, perform the following steps:

    1. Create a content type and add the Custom field to it.
    2. Under Select Extension, select the “Cloudinary” field that you created and set the other properties. You can add other fields as per requirements.cloudinary.png
    3. Finally, click on either Save or Save and Close to save your changes.
    4. Next, create an entry for this content type, and you will see the Cloudinary field in action.Entry PAge.png

    5. Click on Choose Assets. If you are still logged into Cloudinary, it will open inside your entry page, from where you can select multiple images and insert them in your entry as shown in the following screenshot:

      Cloudinary Modal.png

Note: The number of items that can be selected depends on the size of the JSON that is to be stored, and currently, only 10 KB of data can be stored. This is due to limitation of the JSON data stored via Custom Field. Refer to our Custom Field Limitation doc for more detail.

Was this article helpful?

Thanks for your feedbackSmile-icon

On This Page

top-arrow