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 asset metadata to specify their display options and replace them whenever necessary. See how to do it all by adding a simple content type.
Table of contents
This guide will use the example of images where you might want to add custom display options 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.
Create 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, similarly to linking authors to articles.
- From the app menu, choose Content model.
- Create a new content type and name it Image.
- Add an Asset element and name it Image – this is where images themselves will be uploaded.
- Limit it to exactly one asset.
- Make it required.
- Add a Rich text element and name it Caption.
- Add a Multiple choice element and name it Width.
- Add options for different image widths.
- Add a Multiple choice element and name it License.
- Add options for different licenses.
- Add a Linked items element and name it Attribution.
- (Optional) Limit it to the Attribution content type.
- Add a Taxonomy element and select your created taxonomy group for image categories.
- Click Save changes.
Group the elements for easier access
When working with your images, your content creators might first want to see the elements that they will use the most. Use content groups to group similar elements together and name them.
For example, you can put Image and Caption in a group named Content, Width in a group named Display options, and Licenses and Attribution in a group named Metadata.
Now that you have a content type set up, you can add new images to hold and manage your content.
Add images to content
Should you use components or linked items?
Linked items might be more useful than components if you need to find the items by taxonomy term, for example. You can't do so with components so your categorization wouldn't work.
Though if categorization is not a must, using components will give you similar benefits and they will instantly become an integral part of your content. See ways to structure your content to find the best fit for your use case.
Single-use images as your default
Whenever you need to insert the image only in one spot, we recommend you start with single-use components.
- In Content & assets, open the content item where you want to place the image.
- Find the rich text element you wish to use.
- Inside the element, click Insert... and then Insert new component.
- In the list of types, select Image.
- Fill in the elements.
Your image component including all of its associated information is now a part of the content item, sharing the item's workflow and lifecycle.
From single-use to re-use
If you later find another use for the content in your component, you can always convert it to a content item by clicking Reuse as content item. This conversion cannot be undone. If done by accident, you can archive the new item and recreate your component.
Reuse images when needed
If you know from the beginning that you want to use your image in multiple places, create a content item.
- In Content & assets, click Create new.
- If collections are available to you, select one for the new content item.
- Choose Image as the content type.
- Type a name in Content Item Name.
- Upload an asset and fill in the other elements as needed.
To add such an image to a content item:
- In Content & assets, open the content item where you want to add the image.
- 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 Insert and then Insert existing item.
- Select your Image item from the list.
Replace reused assets
When you have your assets inside content items, replacing them across your entire project is simple. 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 one content item and it will be updated everywhere.
To replace one image with another:
- In Content & assets, enter the name of the image item in the filter at the top.
- Open the filtered out content item.
- (If your item is published) Click Create a new version at the top.
- Remove the current image and add a new one.
- (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).
Manage 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.
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 updated across your site.