Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media Picker 3 documentation #3106

Merged
merged 26 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6b886d9
Media Picker 3 documentation
nielslyngsoe Apr 7, 2021
ffe151f
Display on the index page
nielslyngsoe Apr 7, 2021
fa346cd
corrected version
nielslyngsoe Apr 7, 2021
7756e30
Adding part about Global Crops
nielslyngsoe Apr 8, 2021
de55389
Update Getting-Started/Backoffice/Property-Editors/Built-in-Property-…
nielslyngsoe Apr 9, 2021
9771dcb
Update Getting-Started/Backoffice/Property-Editors/Built-in-Property-…
nielslyngsoe Apr 9, 2021
0f414b6
Update Getting-Started/Backoffice/Property-Editors/Built-in-Property-…
nielslyngsoe Apr 9, 2021
e668f0a
Update Getting-Started/Backoffice/Property-Editors/Built-in-Property-…
nielslyngsoe Apr 9, 2021
57f25cf
Update Getting-Started/Backoffice/Property-Editors/Built-in-Property-…
nielslyngsoe Apr 13, 2021
266c366
Update Getting-Started/Backoffice/Property-Editors/Built-in-Property-…
nielslyngsoe Apr 13, 2021
1c8123a
Update Getting-Started/Backoffice/Property-Editors/Built-in-Property-…
nielslyngsoe Apr 13, 2021
346c0d7
Update Getting-Started/Backoffice/Property-Editors/Built-in-Property-…
nielslyngsoe Apr 13, 2021
6c2f48e
Image croppings description
nielslyngsoe Apr 13, 2021
f495240
Merge branch 'v813/media-picker-3' of https://github.com/umbraco/Umbr…
nielslyngsoe Apr 13, 2021
c81a6be
Update Getting-Started/Backoffice/Property-Editors/Built-in-Property-…
nielslyngsoe Apr 13, 2021
4b9c22c
Update Getting-Started/Backoffice/Property-Editors/Built-in-Property-…
nielslyngsoe Apr 13, 2021
9c15052
Update Getting-Started/Backoffice/Property-Editors/Built-in-Property-…
nielslyngsoe Apr 13, 2021
2f7b8f7
Update Getting-Started/Backoffice/Property-Editors/Built-in-Property-…
nielslyngsoe Apr 13, 2021
b7c63ca
Update index.md
sofietoft Apr 14, 2021
1fdc3b1
Update index.md
sofietoft Apr 14, 2021
f49e033
Update index.md
nielslyngsoe May 17, 2021
51cbac7
Update Getting-Started/Backoffice/Property-Editors/Built-in-Property-…
nielslyngsoe May 18, 2021
186d47b
Update Getting-Started/Backoffice/Property-Editors/Built-in-Property-…
nielslyngsoe May 18, 2021
6484ea8
mention Media Picker 3 in Image Cropper
nielslyngsoe May 18, 2021
c517063
added notice about media picker 3 in media picker *old*
nielslyngsoe May 18, 2021
0c2b7aa
Merge branch 'main' into v813/media-picker-3
sofietoft May 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
---
versionFrom: 8.13.0
---

# Media Picker #

`Alias: Umbraco.MediaPicker3`

`Returns: IEnumerable<MediaWithCrops>` or `MediaWithCrops`

This property editors returns a single `MediaWithCrops` 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](images/Media-Picker3-DataType.jpg)

### Accepted types

Use setting to limit the picker to only select Media Items of these types.

### Pick multiple items

Use this setting to enable the property to contain multiple items, when this is turned on the property editor returns a `IEnumerable<MediaWithCrops>`. You can still set the Maximum Amount to 1, do so if you like to retrive a collection but only allowing the Content Editors to select one Media Item.
nielslyngsoe marked this conversation as resolved.
Show resolved Hide resolved

### Amount

Use this setting to enforce a certain minimum or maximum amount of selected Media Items, the maximum setting is unuseable when multiple items is disabled.
nielslyngsoe marked this conversation as resolved.
Show resolved Hide resolved

### Start node

Limit the picker to only work in a certain part of the Media Tree.
nielslyngsoe marked this conversation as resolved.
Show resolved Hide resolved

### Ignorer user start nodes

Use setting to overrule user permissions, to enable any user of this property to pick any Media Item of the choosen Start node.
nielslyngsoe marked this conversation as resolved.
Show resolved Hide resolved

When this setting is enabled, a user who doesn't normally have access to the media selected as "Start Node" (/Design in this case), can access the media when using this particular Media Picker. If no Start node has been defined for this property any content can be viewed and selected of this property.


### Image Croppings

Define local image croppings, this data will stay locally, meaning that this will be stored on the document in this property.
nielslyngsoe marked this conversation as resolved.
Show resolved Hide resolved

## Content Example

![Media Picker Content](images/Media-Picker3-Content.jpg)

## MVC View Example

### Multiple enabled without Modelsbuilder

```csharp
@{
var typedMultiMediaPicker = Model.Value<IEnumerable<MediaWithCrops>>("medias");
foreach (var entry in typedMultiMediaPicker)
{
<img src="@entry.MediaItem.Url" style="width:200px"/>
}
}
```

### Multiple enabled with Modelsbuilder

```csharp
@{
var typedMultiMediaPicker = Model.Medias;
foreach (var entry in typedMultiMediaPicker)
{
<img src="@entry.MediaItem.Url" style="width:200px" />
}
}
```

## Multiple disabled without Modelsbuilder
nielslyngsoe marked this conversation as resolved.
Show resolved Hide resolved

```csharp
@{
var typedMediaPickerSingle = Model.Value<MediaWithCrops>("media");
if (typedMediaPickerSingle != null)
{
<p>@typedMediaPickerSingle.MediaItem.Url</p>
nielslyngsoe marked this conversation as resolved.
Show resolved Hide resolved
<img src="@typedMediaPickerSingle.MediaItem.Url" style="width:200px" alt="@typedMediaPickerSingle.MediaItem.Value("alt")" />
}
}
```

## Multiple disabled with Modelsbuilder
nielslyngsoe marked this conversation as resolved.
Show resolved Hide resolved

```csharp
@{
var typedMediaPickerSingle = Model.FeaturedBanner;
nielslyngsoe marked this conversation as resolved.
Show resolved Hide resolved
if (typedMediaPickerSingle is MediaWithCrops mediaEntry)
{
<p>@mediaEntry.MediaItem.Url</p>
nielslyngsoe marked this conversation as resolved.
Show resolved Hide resolved
<img src="@mediaEntry.MediaItem.Url" style="width:200px"/>
}
}
```

## Using local crops

Local image croppings are stored and retrived different than global crops, below is two examples of how to retrive local crops.
nielslyngsoe marked this conversation as resolved.
Show resolved Hide resolved

### Using GetLocalCropUrl

```csharp
@{
foreach (var entry in Model.Medias)
{
<img src="@entry.GetLocalCropUrl("cropAlias")"/>
}
}
```

### Using UrlHelper

```csharp
@{
foreach (var entry in Model.Medias)
{
<img src="@Url.GetCropUrl(entry.LocalCrops, "cropAlias")"/>
}
}
```

## Use global crops

Global image croppings are croppes stored on the Media Item, by the Property Editor `Image Cropper`, making it shared between all usages of the media Item.
nielslyngsoe marked this conversation as resolved.
Show resolved Hide resolved

The global crops are configured on the DataType of the `umbracoFile` property on the Media Type `Image`

[Read about the Image Cropper here](../Image-Cropper/index.md)

### Using GetCropUrl

```csharp
@{
foreach (var entry in Model.Medias)
{
<img src="@entry.MediaItem.GetCropUrl("cropAlias")"/>
}
}
```

### Using UrlHelper

```csharp
@{
foreach (var entry in Model.Medias)
{
<img src="@Url.GetCropUrl(entry.MediaItem, "cropAlias")"/>
}
}

## Add values programmatically

```This is not part of the current Media Picker v3, feel free to provide such.```
nielslyngsoe marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ This control gives the same functionality as the standard listview, but allows y

The markdown editor will be interpreted by the Models Builder. Behind the scenes, Umbraco uses the [Markdown NuGet package](https://www.nuget.org/packages/Markdown/).

## [Media Picker 3](Media-Picker-3/index.md)
nielslyngsoe marked this conversation as resolved.
Show resolved Hide resolved

`Alias: Umbraco.MediaPicker3`

Media picker 3 is the latest Media Picker, which enables to select one or more medias from the Media Section. This Property Editor can be configured to only pick certain Media Types. And its possible to define Local Image Crops.
nielslyngsoe marked this conversation as resolved.
Show resolved Hide resolved

## [Media Picker](Media-Picker/index.md)
nielslyngsoe marked this conversation as resolved.
Show resolved Hide resolved

`Alias: Umbraco.MediaPicker`
Expand Down