Add Media as a field type via Contentful CLI

Hi lovely people,

I am trying to use the CLI to add a field type Media but I get an error. Is there any way to use createFiled() to create a field type where our content writers could add images, etc.

1 Like

I also would like to know how to do it, because in the following documentation:

There is no “Media” value in “type” property so I did something like :
media.createField(“asset”)
.name(‘asset’)
.type(‘Link’)
.linkType(‘Media’)
.validations([
{linkContentType: [‘Audio’, ‘Video’]}
])
.localized(false);
I don’t know if this is the good way to do it.

Here is the good way:
media.createField(“asset”)
.name(‘asset’)
.type(‘Link’)
.linkType(‘Asset’)
.validations([
{linkMimetypeGroup: [‘audio’, ‘video’]}
])
.required(false)
.localized(true);