We have moved!

You are currently looking at documentation for Umbraco 8 and older versions.
Go to docs.umbraco.com/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/media-picker for documentation for Umbraco 9 and newer versions.

    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)
            <img src="@typedMediaPickerSingle.Url" style="width:200px" alt="@typedMediaPickerSingle.Value("alt")" />