Search Results for

    Show / Hide Table of Contents
    View Source

    Class MediaPickerWithCropsValueConverter

    Converts the value stored by the Media Picker with Crops property editor into a strongly-typed object representing the selected media item(s) and their associated crop data, making it accessible for use in code.

    Inheritance
    object
    PropertyValueConverterBase
    Namespace: Umbraco.Cms.Core.PropertyEditors.ValueConverters
    Assembly: Umbraco.Infrastructure.dll
    Syntax
    [DefaultPropertyValueConverter]
    public class MediaPickerWithCropsValueConverter : PropertyValueConverterBase, IDeliveryApiPropertyValueConverter, IPropertyValueConverter, IDiscoverable

    Constructors

    View Source

    MediaPickerWithCropsValueConverter(IPublishedMediaCache, IPublishedUrlProvider, IPublishedValueFallback, IJsonSerializer, IApiMediaWithCropsBuilder)

    Initializes a new instance of the MediaPickerWithCropsValueConverter class.

    Declaration
    public MediaPickerWithCropsValueConverter(IPublishedMediaCache publishedMediaCache, IPublishedUrlProvider publishedUrlProvider, IPublishedValueFallback publishedValueFallback, IJsonSerializer jsonSerializer, IApiMediaWithCropsBuilder apiMediaWithCropsBuilder)
    Parameters
    Type Name Description
    IPublishedMediaCache publishedMediaCache

    Provides access to the cache of published media items.

    IPublishedUrlProvider publishedUrlProvider

    Resolves URLs for published content and media.

    IPublishedValueFallback publishedValueFallback

    Handles fallback logic for published property values.

    IJsonSerializer jsonSerializer

    Serializes and deserializes JSON data for property values.

    IApiMediaWithCropsBuilder apiMediaWithCropsBuilder

    Builds API representations of media items with crop data.

    Methods

    View Source

    ConvertIntermediateToDeliveryApiObject(IPublishedElement, IPublishedPropertyType, PropertyCacheLevel, object?, bool, bool)

    Converts the intermediate value representing media with crops to an object suitable for the Delivery API.

    Declaration
    public object? ConvertIntermediateToDeliveryApiObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object? inter, bool preview, bool expanding)
    Parameters
    Type Name Description
    IPublishedElement owner

    The published element that owns the property.

    IPublishedPropertyType propertyType

    Metadata describing the property type.

    PropertyCacheLevel referenceCacheLevel

    The cache level for property references.

    object inter

    The intermediate value to convert, typically a MediaWithCrops instance or a collection thereof.

    bool preview

    Indicates whether the conversion is for preview mode.

    bool expanding

    Indicates whether nested objects should be expanded during conversion.

    Returns
    Type Description
    object

    An array of IApiMediaWithCrops representing the media items with crops for the Delivery API. Returns an empty array if no media items are present. For single media items, the result is a single-element array.

    View Source

    ConvertIntermediateToObject(IPublishedElement, IPublishedPropertyType, PropertyCacheLevel, object?, bool)

    Converts the intermediate value produced by the media picker with crops property editor into its final strongly-typed object representation.

    Declaration
    public override object? ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object? inter, bool preview)
    Parameters
    Type Name Description
    IPublishedElement owner

    The published element that contains the property being converted.

    IPublishedPropertyType propertyType

    The type information for the property being converted.

    PropertyCacheLevel referenceCacheLevel

    The cache level to use for resolving referenced entities.

    object inter

    The intermediate value to convert, typically a JSON string or deserialized object.

    bool preview

    True if the conversion is for preview mode; otherwise, false.

    Returns
    Type Description
    object

    If the property is configured for multiple selection, returns an System.Collections.Generic.IEnumerable<T> containing the selected media items with crop data; if single selection, returns a single MediaWithCrops instance, or null if no value is present.

    View Source

    GetDeliveryApiPropertyCacheLevel(IPublishedPropertyType)

    Determines the cache level to use for the delivery API when accessing a media picker property with crops.

    Declaration
    public PropertyCacheLevel GetDeliveryApiPropertyCacheLevel(IPublishedPropertyType propertyType)
    Parameters
    Type Name Description
    IPublishedPropertyType propertyType

    The published property type for which to determine the cache level.

    Returns
    Type Description
    PropertyCacheLevel

    The PropertyCacheLevel to be used for the delivery API.

    View Source

    GetDeliveryApiPropertyCacheLevelForExpansion(IPublishedPropertyType)

    Determines the PropertyCacheLevel to use when expanding a media picker property for the Delivery API.

    Declaration
    public PropertyCacheLevel GetDeliveryApiPropertyCacheLevelForExpansion(IPublishedPropertyType propertyType)
    Parameters
    Type Name Description
    IPublishedPropertyType propertyType

    The IPublishedPropertyType representing the property being expanded.

    Returns
    Type Description
    PropertyCacheLevel

    The appropriate PropertyCacheLevel for Delivery API expansion.

    View Source

    GetDeliveryApiPropertyValueType(IPublishedPropertyType)

    Gets the type used for delivery API property values for the specified published property type.

    Declaration
    public Type GetDeliveryApiPropertyValueType(IPublishedPropertyType propertyType)
    Parameters
    Type Name Description
    IPublishedPropertyType propertyType

    The published property type.

    Returns
    Type Description
    Type

    The System.Collections.Generic.IEnumerable<T> type used for delivery API property values.

    View Source

    GetPropertyCacheLevel(IPublishedPropertyType)

    Gets the cache level that should be used for the specified media picker property type.

    Declaration
    public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
    Parameters
    Type Name Description
    IPublishedPropertyType propertyType

    The published property type for which to determine the cache level.

    Returns
    Type Description
    PropertyCacheLevel

    Always returns Snapshot, indicating the value is cached at the snapshot level.

    View Source

    GetPropertyValueType(IPublishedPropertyType)

    Determines the CLR type returned for the property value, based on whether the property type allows multiple values.

    Declaration
    public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
    Parameters
    Type Name Description
    IPublishedPropertyType propertyType

    The published property type to inspect.

    Returns
    Type Description
    Type

    System.Collections.Generic.IEnumerable<T> if the property type allows multiple values; otherwise, MediaWithCrops.

    View Source

    IsConverter(IPublishedPropertyType)

    Determines whether this converter applies to the specified property type.

    Declaration
    public override bool IsConverter(IPublishedPropertyType propertyType)
    Parameters
    Type Name Description
    IPublishedPropertyType propertyType

    The property type to check.

    Returns
    Type Description
    bool

    true if this converter is applicable; otherwise, false.

    View Source

    IsValue(object?, PropertyValueLevel)

    Determines whether the specified value should be considered a valid property value at the given level. For the Source level, this method also checks that the value is not an empty JSON array ("[]").

    Declaration
    public override bool? IsValue(object? value, PropertyValueLevel level)
    Parameters
    Type Name Description
    object value

    The value to evaluate for validity.

    PropertyValueLevel level

    The property value level at which to evaluate the value.

    Returns
    Type Description
    bool?

    true if the value is valid; false if it is not valid; or null if the validity cannot be determined.

    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX