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 payloadLink 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.
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:
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.
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.