MediaType
A MediaType is almost the same as a ContentType. I.e. a model / data definition for your media nodes.
A MediaType is almost the same as a ContentType, that is, a model / data definition for your media nodes
You can set icon, thumbnail and description. It is also possible to add groups and properties.
A Media Type differs from a Document Type in that it has no templates.
Namespace:
Umbraco.Cms.Core.Models
Assembly:
Umbraco.Core.dll
All samples in this document will require references to the following dll:
Umbraco.Core.dll
All samples in this document will require the following using statements:
Constructors
new MediaType(IShortStringHelper shortStringHelper, int parentId)
Constructor for creating a new MediaType
object where the necessary parameters are a short string helper IShortStringHelper
and the Id of the parent MediaType
as an Int
.
new MediaType(IShortStringHelper shortStringHelper,IMediaType parent)
Constructor for creating a new MediaType
object where the necessary parameter are a short string helper IShortStringHelper
and the parent MediaType
as an IMediaType
object.
new MediaType(IShortStringHelper shortStringHelper, IMediaType parent, string alias)
This constructor creates a new MediaType
object and requires the following parameters: a short string helper IShortStringHelper
and the parent MediaType
as an IMediaType
object. Additionally, the alias of the MediaType
should be provided as a string
.
Properties
.Alias
Gets or Sets the Alias as a String
of the MediaType.
.AllowedContentTypes
Gets or Sets an Enumerable
list of ContentTypeSort
objects of the MediaTypes allowed under the current MediaType.
The ContentTypeSort
is an object with a lazy Id, int SortOrder and string Alias used to sort the MediaTypes within the list of AllowedContentTypes.
.ContentTypeComposition
Gets a list of MediaTypes
as IContentTypeComposition
objects that make up a composition of PropertyGroups and PropertyTypes for the current MediaType.
The ContentTypeComposition
provides a mixin-type functionality in that you can compose a MediaType of one or more other MediaTypes in a complex structure. But please keep in mind that the backoffice does not fully support these complex structures yet
.CompositionPropertyGroups
Gets a list of all PropertyGroup
objects from the composition including PropertyGroups from the current MediaType.
.CompositionPropertyTypes
Gets a list of all PropertyType
objects from the composition including PropertyTypes from the current MediaType.
.CreateDate
Gets or Sets a DateTime
object, indicating then the given MediaType was created.
.CreatorId
Gets or Sets the Id of the User
who created the MediaType.
.Description
Gets or Sets the Description as a String
for the MediaType.
.Icon
Gets or Sets the Icon as a String
for the MediaType.
.Id
Retrieves the unique MediaType
ID as an Int
. This ID is based on a Database identity field and is therefore not safe to reference in code when moved between different instances.
.Key
Gets the Guid
assigned to the MediaType during creation. This value is unique, and should never change, even if the content is moved between instances.
.Level
Gets or Sets the given MediaType
level in the site hierarchy as an Int
. MediaTypes placed at the root of the tree, will return 1, content right underneath will return 2, and so on.
.Name
Gets or Sets the name of the MediaType as a String
.
.ParentId
Gets or Sets the parent MediaType
Id as an Int
.
.Path
Gets or Sets the path of the MediaType as a String
. This string contains a comma separated list of the ancestor Ids including the current MediaTypes own id at the end of the string.
.PropertyGroups
Gets or Sets a PropertyGroupCollection
containing a list of PropertyGroups for the current MediaType.
.PropertyTypes
Gets an Enumerable
list of PropertyTypes aggregated for all groups within the current MediaType, as well as PropertyTypes not within a group.
.SortOrder
Gets the given MediaType
index, compared to sibling content.
.Thumbnail
Gets or Sets the Thumbnail as a String
for the MediaType.
Methods
.AddContentType(IContentTypeComposition mediaType)
Adds a new MediaType
to the list of composite MediaTypes.
.CompositionAliases()
Returns an Enumerable
list of MediaType aliases as String
from the current composition.
.CompositionIds()
Returns an Enumerable
list of MediaType Ids as Int
from the current composition.
.ContentTypeCompositionExists(string alias)
Checks if a MediaType
with the supplied alias exists in the list of composite MediaTypes.
.RemoveContentType(string alias)
Removes a MediaType
with the supplied alias from the list of composite MediaTypes.
.RemovePropertyType(string propertyTypeAlias)
Removes a PropertyType
from the current MediaType
.
Last updated