Note
Media types must first be defined in your content model for built-in asset functionality such as file upload or drag-and-drop to work in edit view. It is recommended that you create specific classes for media of type images, video, and anything generic other than video or image, such as text or PDF files.
Media and media types work as follows:
A _media type_ defines a set of properties.
A media is an instance of the .NET class that defined the media type.
When an editor creates/uploads media, values are assigned to the properties defined by the media type.
When an instance of media is requested by a visitor, the default media handler sends the binary data to the visitor.
During initialization, assemblies in the bin folder are scanned for .NET classes decorated with the \`\[ContentType\]` attribute, and inheriting fromÂ
`MediaData\`. Meta data for media is defined as properties on the media class, and can be edited from edit view.
## Generic media type
You can use the Episerver Visual Studio extensions to create media types. The example below shows a generic media type for handling files, inheriting from `MediaData
`, with a description property available under the **Content** tab in edit view.
### MediaDescriptor attribute
The `MediaDescriptor
`Â attribute defines a list of file extensions and associates specific file types with a given content type, which creates content of the correct content type when a user uploads media via the user interface.
When you create media content from the server side, you also can have this same content type resolve by using the `ContentMediaResolver
`.
## Specialized media types
`ImageData
` and `VideoData
` are specialized base classes distinguishing images and videos from other generic media, to apply special handling in edit view. For example, media types inheriting ImageData will display image _thumbnails_ when listing images in the **Media** folder in edit view. Both `ImageData
` and `VideoData
` inherit from `MediaData
`.

**Example:** Media type for images, inheriting from `ImageData
`, and with properties for copyright and a description.
The `UIHint
` property attribute is used to select either editor/renderer or both by defining a hint string. You can use `EPiServer.Web.UIHint
` for known types in the system, for instance `UIHint.Image
`.
**Example:**Â Media type for videos, inheriting from `VideoData
`, and with properties for copyright and link to video preview image.
## ImageDescriptor attribute
The `ImageDescriptor
` attribute automatically generates scaled images. When you route to a BLOB type property, CMS determines whether the BLOB is null and the property has an `ImageDescriptor
` attribute. If both are true, a scaled image is automatically generated from `IBinaryStorable.BinaryData
`.
**Example:** The `ImageData.Thumbnail
` property with an `ImageDescriptor
` attribute.
## Media structure
Media is structured using folders. A folder in the media structure can have other folders or media as children, but a media instance cannot have any children. You can set access rights on folders to control availability for editors.Â
The media structure is defined by the following criteria:
The **global** media root folder is set as `
GlobalAssetsRoot
`, defining media available for content on all sites in a mult-site scenario.A **site-specific** media root folder is set as `
SiteAssetsRoot
`, defining media only available for a specific site in a multi-site scenario. In a single site scenario, the `GlobalAssetsRoot
` and `SiteAssetRoot
` will typically point to the same folder.A **folder**Â is an instance of `
ContentFolder
`, and is used to structure content. A content folder does not have any associated rendering, and will not appear on the site.
See  `SiteDefinition
` in the [Optimizely CMS class library](🔗).
## Change the maximum upload file size
In _web.config_, change the parameters `maxAllowedContentLength
` and `maxRequestLength
`:
## Customize the media handler
The built-in `EPiServer.Web.ContentMediaHttpHandler
` delivers all media by default. However, if you want custom processing before sending the media to the visitor, the example below shows how you can implement your own HTTP handler. Handlers for media uses the same templating system as other content types in Episerver, which means you can use any type of template for media; you are not limited to HTTP handlers.
You can base your custom transmitter implementation on either `EPiServer.Web.BlobHttpHandler
` or `EPiServer.Web.MediaHandlerBase
`, and use the `TransmitFile
` method for transmittance of file data.