Class MediaServiceExtensions
Media service extension methods
Inheritance
object
Namespace: Umbraco.Extensions
Assembly: Umbraco.Core.dll
Syntax
public static class MediaServiceExtensions
Remarks
Many of these have to do with UDI lookups but we don't need to add these methods to the service interface since a UDI is just a GUID and the services already support GUIDs
Methods
View SourceCreateMedia(IMediaService, string, Udi, string, int)
Creates a new media item under a parent specified by UDI.
Declaration
public static IMedia CreateMedia(this IMediaService mediaService, string name, Udi parentId, string mediaTypeAlias, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IMediaService | mediaService | The media service. |
| string | name | The name of the new media item. |
| Udi | parentId | The UDI of the parent media item. |
| string | mediaTypeAlias | The alias of the media type. |
| int | userId | The ID of the user creating the media item. |
Returns
| Type | Description |
|---|---|
| IMedia | The newly created media item. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when the UDI is not of type GuidUdi. |
GetByIds(IMediaService, IEnumerable<Udi>)
Gets a collection of media items by their UDIs.
Declaration
public static IEnumerable<IMedia> GetByIds(this IMediaService mediaService, IEnumerable<Udi> ids)
Parameters
| Type | Name | Description |
|---|---|---|
| IMediaService | mediaService | The media service. |
| IEnumerable<Udi> | ids | The collection of UDIs to retrieve. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IMedia> | A collection of media items. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when a UDI is not of type GuidUdi. |