Defines the Media Service, which is an easy access to operations involving IMedia
Namespace: Umbraco.Cms.Core.Services Assembly: Umbraco.Core.dll Syntaxpublic interface IMediaService : IContentServiceBase<IMedia>, IContentServiceBase, IService
Methods View Source Count(String) Declaration
int Count(string mediaTypeAlias = null)
Parameters Type Name Description System.String mediaTypeAlias Returns Type Description System.Int32 View Source CountChildren(Int32, String) Declaration
int CountChildren(int parentId, string mediaTypeAlias = null)
Parameters Type Name Description System.Int32 parentId System.String mediaTypeAlias Returns Type Description System.Int32 View Source CountDescendants(Int32, String) Declaration
int CountDescendants(int parentId, string mediaTypeAlias = null)
Parameters Type Name Description System.Int32 parentId System.String mediaTypeAlias Returns Type Description System.Int32 View Source CountNotTrashed(String) Declaration
int CountNotTrashed(string contentTypeAlias = null)
Parameters Type Name Description System.String contentTypeAlias Returns Type Description System.Int32 View Source CreateMedia(String, Guid, String, Int32)
Creates an IMedia object using the alias of the IMediaType that this Media should based on.
DeclarationIMedia CreateMedia(string name, Guid parentId, string mediaTypeAlias, int userId = -1)
Parameters Type Name Description System.String name
Name of the Media object
Guid parentIdId of Parent for the new Media item
System.String mediaTypeAliasAlias of the IMediaType
System.Int32 userIdOptional id of the user creating the media item
Returns View Source CreateMedia(String, Int32, String, Int32)Creates an IMedia object using the alias of the IMediaType that this Media should based on.
DeclarationIMedia CreateMedia(string name, int parentId, string mediaTypeAlias, int userId = -1)
Parameters Type Name Description System.String name
Name of the Media object
System.Int32 parentIdId of Parent for the new Media item
System.String mediaTypeAliasAlias of the IMediaType
System.Int32 userIdOptional id of the user creating the media item
Returns View Source CreateMedia(String, IMedia, String, Int32)Creates an IMedia object using the alias of the IMediaType that this Media should based on.
DeclarationIMedia CreateMedia(string name, IMedia parent, string mediaTypeAlias, int userId = -1)
Parameters Type Name Description System.String name
Name of the Media object
IMedia parentParent IMedia for the new Media item
System.String mediaTypeAliasAlias of the IMediaType
System.Int32 userIdOptional id of the user creating the media item
Returns View Source CreateMediaWithIdentity(String, Int32, String, Int32)Creates an IMedia object using the alias of the IMediaType that this Media should based on.
DeclarationIMedia CreateMediaWithIdentity(string name, int parentId, string mediaTypeAlias, int userId = -1)
Parameters Type Name Description System.String name
Name of the Media object
System.Int32 parentIdId of Parent for the new Media item
System.String mediaTypeAliasAlias of the IMediaType
System.Int32 userIdOptional id of the user creating the media item
Returns View Source CreateMediaWithIdentity(String, IMedia, String, Int32)Creates an IMedia object using the alias of the IMediaType that this Media should based on.
DeclarationIMedia CreateMediaWithIdentity(string name, IMedia parent, string mediaTypeAlias, int userId = -1)
Parameters Type Name Description System.String name
Name of the Media object
IMedia parentParent IMedia for the new Media item
System.String mediaTypeAliasAlias of the IMediaType
System.Int32 userIdOptional id of the user creating the media item
Returns View Source Delete(IMedia, Int32)Permanently deletes an IMedia object
DeclarationAttempt<OperationResult> Delete(IMedia media, int userId = -1)
Parameters Type Name Description IMedia media
The IMedia to delete
System.Int32 userIdId of the User deleting the Media
Returns View Source DeleteMediaFile(String)Deletes a media file.
Declarationvoid DeleteMediaFile(string filepath)
Parameters Type Name Description System.String filepath
The filesystem path to the media.
View Source DeleteMediaOfType(Int32, Int32)Deletes all media of specified type. All children of deleted media is moved to Recycle Bin.
Declarationvoid DeleteMediaOfType(int mediaTypeId, int userId = -1)
Parameters Type Name Description System.Int32 mediaTypeId
Id of the IMediaType
System.Int32 userIdOptional Id of the user deleting Media
View Source DeleteMediaOfTypes(IEnumerable<Int32>, Int32)Deletes all media of the specified types. All Descendants of deleted media that is not of these types is moved to Recycle Bin.
Declarationvoid DeleteMediaOfTypes(IEnumerable<int> mediaTypeIds, int userId = -1)
Parameters Type Name Description IEnumerable<System.Int32> mediaTypeIds
Ids of the IMediaTypes
System.Int32 userIdOptional Id of the user issuing the delete operation
View Source DeleteVersion(Int32, Int32, Boolean, Int32)Permanently deletes specific version(s) from an IMedia object.
Declarationvoid DeleteVersion(int id, int versionId, bool deletePriorVersions, int userId = -1)
Parameters Type Name Description System.Int32 id
Id of the IMedia object to delete a version from
System.Int32 versionIdId of the version to delete
System.Boolean deletePriorVersionsBoolean indicating whether to delete versions prior to the versionId
System.Int32 userIdOptional Id of the User deleting versions of a Content object
View Source DeleteVersions(Int32, DateTime, Int32)Permanently deletes versions from an IMedia object prior to a specific date.
Declarationvoid DeleteVersions(int id, DateTime versionDate, int userId = -1)
Parameters Type Name Description System.Int32 id
Id of the IMedia object to delete versions from
DateTime versionDateLatest version date
System.Int32 userIdOptional Id of the User deleting versions of a Content object
View Source EmptyRecycleBin(Int32)Empties the Recycle Bin by deleting all IMedia that resides in the bin
DeclarationOperationResult EmptyRecycleBin(int userId = -1)
Parameters Type Name Description System.Int32 userId
Optional Id of the User emptying the Recycle Bin
Returns View Source EmptyRecycleBinAsync(Guid) DeclarationTask<OperationResult> EmptyRecycleBinAsync(Guid userId)
Parameters Type Name Description Guid userId Returns View Source GetAncestors(Int32)
Gets a collection of IMedia objects, which are ancestors of the current media.
DeclarationIEnumerable<IMedia> GetAncestors(int id)
Parameters Type Name Description System.Int32 id
Id of the IMedia to retrieve ancestors for
Returns Type Description IEnumerable<IMedia>An Enumerable list of IMedia objects
View Source GetAncestors(IMedia)Gets a collection of IMedia objects, which are ancestors of the current media.
DeclarationIEnumerable<IMedia> GetAncestors(IMedia media)
Parameters Type Name Description IMedia media
IMedia to retrieve ancestors for
Returns Type Description IEnumerable<IMedia>An Enumerable list of IMedia objects
View Source GetById(Guid)Gets an IMedia object by its 'UniqueId'
Declaration Parameters Type Name Description Guid keyGuid key of the Media to retrieve
Returns View Source GetById(Int32)Gets an IMedia object by Id
Declaration Parameters Type Name Description System.Int32 idId of the Content to retrieve
Returns View Source GetByIds(IEnumerable<Guid>) DeclarationIEnumerable<IMedia> GetByIds(IEnumerable<Guid> ids)
Parameters Type Name Description IEnumerable<Guid> ids Returns Type Description IEnumerable<IMedia> View Source GetByIds(IEnumerable<Int32>) Declaration
IEnumerable<IMedia> GetByIds(IEnumerable<int> ids)
Parameters Type Name Description IEnumerable<System.Int32> ids Returns Type Description IEnumerable<IMedia> View Source GetByLevel(Int32)
Gets a collection of IMedia objects by Level
DeclarationIEnumerable<IMedia>? GetByLevel(int level)
Parameters Type Name Description System.Int32 level
The level to retrieve Media from
Returns Type Description System.Nullable<IEnumerable<IMedia>>An Enumerable list of IMedia objects
View Source GetMediaByPath(String)Gets an IMedia object from the path stored in the 'umbracoFile' property.
DeclarationIMedia GetMediaByPath(string mediaPath)
Parameters Type Name Description System.String mediaPath
Path of the media item to retrieve (for example: /media/1024/koala_403x328.jpg)
Returns View Source GetMediaFileContentStream(String)Gets the content of a media as a stream.
DeclarationStream GetMediaFileContentStream(string filepath)
Parameters Type Name Description System.String filepath
The filesystem path to the media.
Returns Type Description StreamThe content of the media.
View Source GetMediaFileSize(String)Gets the size of a media.
Declarationlong GetMediaFileSize(string filepath)
Parameters Type Name Description System.String filepath
The filesystem path to the media.
Returns Type Description System.Int64The size of the media.
View Source GetPagedChildren(Int32, Int64, Int32, out Int64, IQuery<IMedia>, Ordering)Gets a collection of IMedia objects by Parent Id
DeclarationIEnumerable<IMedia> GetPagedChildren(int id, long pageIndex, int pageSize, out long totalRecords, IQuery<IMedia> filter = null, Ordering ordering = null)
Parameters Type Name Description System.Int32 id
Id of the Parent to retrieve Children from
System.Int64 pageIndexPage number
System.Int32 pageSizePage size
System.Int64 totalRecordsTotal records query would return without paging
IQuery<IMedia> filter Ordering ordering Returns Type Description IEnumerable<IMedia>An Enumerable list of IContent objects
View Source GetPagedDescendants(Int32, Int64, Int32, out Int64, IQuery<IMedia>, Ordering)Gets a collection of IMedia objects by Parent Id
DeclarationIEnumerable<IMedia> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalRecords, IQuery<IMedia> filter = null, Ordering ordering = null)
Parameters Type Name Description System.Int32 id
Id of the Parent to retrieve Descendants from
System.Int64 pageIndexPage number
System.Int32 pageSizePage size
System.Int64 totalRecordsTotal records query would return without paging
IQuery<IMedia> filter Ordering ordering Returns Type Description IEnumerable<IMedia>An Enumerable list of IContent objects
View Source GetPagedMediaInRecycleBin(Int64, Int32, out Int64, IQuery<IMedia>, Ordering)Gets a collection of an IMedia objects, which resides in the Recycle Bin
DeclarationIEnumerable<IMedia> GetPagedMediaInRecycleBin(long pageIndex, int pageSize, out long totalRecords, IQuery<IMedia> filter = null, Ordering ordering = null)
Parameters Type Name Description System.Int64 pageIndex System.Int32 pageSize System.Int64 totalRecords IQuery<IMedia> filter Ordering ordering Returns Type Description IEnumerable<IMedia>
An Enumerable list of IMedia objects
View Source GetPagedOfType(Int32, Int64, Int32, out Int64, IQuery<IMedia>, Ordering)Gets paged documents of a content
DeclarationIEnumerable<IMedia> GetPagedOfType(int contentTypeId, long pageIndex, int pageSize, out long totalRecords, IQuery<IMedia> filter = null, Ordering ordering = null)
Parameters Type Name Description System.Int32 contentTypeId
The page number.
System.Int64 pageIndexThe page number.
System.Int32 pageSizeThe page size.
System.Int64 totalRecordsTotal number of documents.
IQuery<IMedia> filterSearch text filter.
Ordering orderingOrdering infos.
Returns Type Description IEnumerable<IMedia> View Source GetPagedOfTypes(Int32[], Int64, Int32, out Int64, IQuery<IMedia>, Ordering)Gets paged documents for specified content types
DeclarationIEnumerable<IMedia> GetPagedOfTypes(int[] contentTypeIds, long pageIndex, int pageSize, out long totalRecords, IQuery<IMedia> filter = null, Ordering ordering = null)
Parameters Type Name Description System.Int32[] contentTypeIds
The page number.
System.Int64 pageIndexThe page number.
System.Int32 pageSizeThe page size.
System.Int64 totalRecordsTotal number of documents.
IQuery<IMedia> filterSearch text filter.
Ordering orderingOrdering infos.
Returns Type Description IEnumerable<IMedia> View Source GetParent(Int32)Gets the parent of the current media as an IMedia item.
Declaration Parameters Type Name Description System.Int32 idId of the IMedia to retrieve the parent from
Returns View Source GetParent(IMedia)Gets the parent of the current media as an IMedia item.
DeclarationIMedia GetParent(IMedia media)
Parameters Type Name Description IMedia media
IMedia to retrieve the parent from
Returns View Source GetRootMedia()Gets a collection of IMedia objects, which reside at the first level / root
DeclarationIEnumerable<IMedia> GetRootMedia()
Returns Type Description IEnumerable<IMedia>
An Enumerable list of IMedia objects
View Source GetVersion(Int32)Gets a specific version of an IMedia item.
DeclarationIMedia GetVersion(int versionId)
Parameters Type Name Description System.Int32 versionId
Id of the version to retrieve
Returns View Source GetVersions(Int32)Gets a collection of an IMedia objects versions by Id
DeclarationIEnumerable<IMedia> GetVersions(int id)
Parameters Type Name Description System.Int32 id Returns Type Description IEnumerable<IMedia>
An Enumerable list of IMedia objects
View Source HasChildren(Int32)Checks whether an IMedia item has any children
Declaration Parameters Type Name Description System.Int32 idId of the IMedia
Returns Type Description System.BooleanTrue if the media has any children otherwise False
View Source Move(IMedia, Int32, Int32)Moves an IMedia object to a new location
DeclarationAttempt<OperationResult> Move(IMedia media, int parentId, int userId = -1)
Parameters Type Name Description IMedia media
The IMedia to move
System.Int32 parentIdId of the Media's new Parent
System.Int32 userIdId of the User moving the Media
Returns View Source MoveToRecycleBin(IMedia, Int32)Deletes an IMedia object by moving it to the Recycle Bin
DeclarationAttempt<OperationResult> MoveToRecycleBin(IMedia media, int userId = -1)
Parameters Type Name Description IMedia media
The IMedia to delete
System.Int32 userIdId of the User deleting the Media
Returns View Source RecycleBinSmells()Returns true if there is any media in the recycle bin
Declaration Returns Type Description System.Boolean View Source Save(IEnumerable<IMedia>, Int32)Saves a collection of IMedia objects
DeclarationAttempt<OperationResult> Save(IEnumerable<IMedia> medias, int userId = -1)
Parameters Type Name Description IEnumerable<IMedia> medias
Collection of IMedia to save
System.Int32 userIdId of the User saving the Media
Returns View Source Save(IMedia, Int32)Saves a single IMedia object
DeclarationAttempt<OperationResult> Save(IMedia media, int userId = -1)
Parameters Type Name Description IMedia media
The IMedia to save
System.Int32 userIdId of the User saving the Media
Returns View Source SetMediaFileContent(String, Stream)Sets the content of a media.
Declarationvoid SetMediaFileContent(string filepath, Stream content)
Parameters Type Name Description System.String filepath
The filesystem path to the media.
Stream contentThe content of the media.
View Source Sort(IEnumerable<IMedia>, Int32)Sorts a collection of IMedia objects by updating the SortOrder according to the ordering of items in the passed in .
Declarationbool Sort(IEnumerable<IMedia> items, int userId = -1)
Parameters Type Name Description IEnumerable<IMedia> items System.Int32 userId Returns Type Description System.Boolean
True if sorting succeeded, otherwise False
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4