Skip to main content

Dynamic Content: MIME types included in content payload

Release date: 29th May 2024

This release features a small, but important update for developers. The MIME type for images and videos is now included in the content payload returned by the Content Delivery API, allowing developers to check the types of media that is returned in the content.

This update to the content payload is particularly useful if you support media served dynamically, such as PNG or JPEG, as well as images that are usually served statically, such as SVGs. By looking at the MIME type, you can now check if an image is in SVG format and if it is, build up a static URL to render it. Previously users would often have to indicate on the content form if an image is in SVG format, and now this check can be done in your rendering code.

Updated content payload
Link copied!

When you retrieve content containing media added using media links, a new field is included in the payload returned by the Content Delivery API: mimeType. For example, this might be "image/jpeg" for an image, or "video/mp4" for video.

In the example below, an SVG image has been added to a content item.

An image in SVG format added to a content item

When this content item is retrieved using its production Content Delivery URL, or the unpublished content with virtual staging, the image property is returned as shown below:

{
"content": {
"_meta": {
"name": "Media example",
"schema": "https://example.com/media",
"deliveryId": "e2153100-f26f-4eb8-92f1-95054484bec6"
},
"image": {
"_meta": {
"schema": "http://bigcontent.io/cms/schema/v1/core#/definitions/image-link"
},
"id": "f6eb6e0e-d3b0-44b0-be54-076b314b7d13",
"name": "model-content",
"endpoint": "ampproduct",
"defaultHost": "cdn.media.amplience.net",
"mimeType": "image/svg+xml"
}
}
}

Because the mimeType indicates that the image is in SVG format, we know that it should be rendered using its static URL: https://ampproduct.a.bigcontent.io/v1/static/model-content.

If the mimeType was an image type that is served dynamically, such as "image/jpeg" or "image/png", we would just build up the dynamic URL from the name, endpoint and defaultHost fields as normal.

info

mimeType is only part of the content playload for content published after this feature was released. If you want to access the mimeType of previously published content, you will need to add the media links and publish it again.