Skip navigation

Using assets in the content model

When you have lots of assets in Kentico Kontent, file organization becomes a must. And not only that. You may want to also manage their metadata and replace them whenever necessary. See how to do it all by adding a simple content type.

This guide will use the example of images where you might want to add custom CSS classes for the image, a category to find the images you're looking for, a license for the image's use, and who created the image. You could easily apply similar principles for other kinds of assets (e-books, videos, etc.) or just have a single type for all assets to manage them together.

Table of contents

    Creating an Image content type

    To be able to add extra information to your images, start by creating a content type to hold them. This assumes you've already created a taxonomy to categorize the images. You may also have created an Attribution content type to hold information about who created the image.

    1. From the app menu, choose .
    2. Create a new content type and name it Image.
    3. Add an Asset content element – this is where images themselves will be uploaded.
      1. Name it Image.
      2. Limit it to exactly one asset.
      3. Make it required.
    4. Add a Text element and name it CSS classes (optional: add guidelines describing how to format the classes).
    5. Add a Taxonomy element and select your created taxonomy group.
    6. Add a Multiple choice element.
      1. Name it License.
      2. Add options for different licenses.
    7. Add a Linked items element.
      1. Name it Attribution.
      2. (Optional) Limit it to the Attribution content type.
    8. Click Save changes.
    A screenshot of the created Image content type.

    Creating Image content items

    Now that you have a content type set up, you can create new Image content items to hold and manage your content.

    1. From the app menu, choose .
    2. Click Create new.
    3. Choose Image as the content type.
    4. Type a name in Content Item Name.
    5. Upload an asset and fill in the other fields as required.
    6. (Optional) Click Publish at the top of the page.
    A screenshot of the created Image content item.

    How your Image content item might look when you're done.

    Adding images to content

    When you have your images ready, you can add them to your content in two ways – either in linked items elements (to replace the use of Asset elements) or inline inside rich text as linked items. Linked items are more useful in this case than components because you can find linked items by taxonomy term, while you can't do so with components so your categorization wouldn't work.

    To add an image to a content item:

    1. From the app menu, choose .
    2. Open the content item where you want the image.
    3. Find the linked items element or rich text element you wish to use.
      • For a linked items element, choose Add existing items
      • For a rich text element, click inside the element, click and then .
    4. Select your Image item (for example, Mosaic, as above) from the list.

    Your image including all of its associated information is now a part of your content item.

    Replacing assets

    When you have your assets inside content items, replacing them across your entire project is much simpler. Instead of needing to go to every content item an asset is used in and replacing it manually, you only need to replace it in the one content item and it will be updated everywhere. To replace one mosaic image with another:

    1. From the app menu, choose  .
    2. Enter Mosaic in the filter at the top and open the Mosaic content item.
    3. (If your item is published) Click Create new version at the top.
    4. Remove the current image and add the new one.
    5. (Optional) Click Publish at the top of the page.

    Now your asset will be automatically replaced wherever it is used (you can see where under Used in in the right sidebar).

    Managing assets in multilingual projects

    If you're using content items to hold your assets and adding them as linked items, it's important for you to understand how language fallbacks work. If you add an Image content item as a linked item in one language (for example, English), it will not appear in any other language (for example, Spanish) unless you translate it into that language. Even if the information you're including in your Image content item is not language-dependent (e.g., it's just the creator's name), you need to create a variant in every language to have it appear. Copying content from the original language can give you a head start.

    What's next?

    You've seen how to create a content type to hold your assets and then add content items based on this type to your content. You can store any information you want in these items, including taxonomies for categorization and any other metadata you want to be associated with the asset. You can also replace your asset in one place and have it update across your site.