Class MediaFileExtensions
Extension methods for reading the file extension of a media item. Both overloads read the stored file; a slim entity already carries its path, a full media item resolves it.
Inheritance
object
Namespace: Umbraco.Extensions
Assembly: Umbraco.Core.dll
Syntax
public static class MediaFileExtensions
Methods
View SourceGetFileExtension(IMediaEntitySlim)
Gets the file extension of a media entity, without the leading dot and in lowercase.
Declaration
public static string? GetFileExtension(this IMediaEntitySlim entity)
Parameters
| Type | Name | Description |
|---|---|---|
| IMediaEntitySlim | entity | The media entity. |
Returns
| Type | Description |
|---|---|
| string | The file extension, or |
GetFileExtension(IMedia, MediaUrlGeneratorCollection)
Gets the file extension of a media item, without the leading dot and in lowercase.
Declaration
public static string? GetFileExtension(this IMedia media, MediaUrlGeneratorCollection mediaUrlGenerators)
Parameters
| Type | Name | Description |
|---|---|---|
| IMedia | media | The media item. |
| MediaUrlGeneratorCollection | mediaUrlGenerators | Used to resolve the stored file's path. |
Returns
| Type | Description |
|---|---|
| string | The file extension, or |