Media Picker

    Alias: Umbraco.MediaPicker

    Returns: IEnumerable<IPublishedContent> or IPublishedContent

    This property editors returns a single item if the "Pick multiple items" data type setting is disabled or a collection if it is enabled.

    Data Type Definition Example

    Media Picker Data Type Definition

    Content Example

    Media Picker Content

    Typed Example (multiple enabled):

    @{
        var typedMultiMediaPicker = Model.Value<IEnumerable<IPublishedContent>>("sliders");
        foreach (var item in typedMultiMediaPicker)
        {
            <img src="@item.Url" style="width:200px"/>
        }
    }
    

    Typed Example (multiple disabled):

    @{
        var typedMediaPickerSingle = Model.Value<IPublishedContent>("featuredBanner");
        if (typedMediaPickerSingle != null)
        {
            <p>@typedMediaPickerSingle.Url</p>
            <img src="@typedMediaPickerSingle.Url" style="width:200px" alt="@typedMediaPickerSingle.Value("alt")" />
        }
    }