Skip to content

Commit 528e421

Browse files
authored
Merge pull request #6732 from umbraco/update-property-editor
Update mediapicker article with an example
2 parents efd7ab5 + 5d17d02 commit 528e421

File tree

3 files changed

+63
-3
lines changed
  • 13/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors
  • 14/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors
  • 15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors

3 files changed

+63
-3
lines changed

13/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/media-picker-3.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

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

7-
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.
7+
This property editors returns one of the following:
8+
9+
- A collection (`IEnumerable<MediaWithCrops>`) if the **Pick multiple items** setting is enabled.
10+
- A single `MediaWithCrops` item if the **Pick multiple items** setting is disabled.
811

912
## Data Type Definition Example
1013

@@ -71,6 +74,23 @@ Global crops are configured on the Image Cropper property of the Image Media Typ
7174
}
7275
```
7376

77+
#### Multiple enabled without Modelsbuilder to retrieve IEnumerable<IPublishedContent> data
78+
79+
```csharp
80+
@using Umbraco.Cms.Core.Models
81+
@{
82+
var listOfImages = Model.Value<IEnumerable<IPublishedContent>>("medias");
83+
foreach (var image in listOfImages)
84+
{
85+
<img src="@image.Url()" alt="@image.Name" />
86+
}
87+
}
88+
```
89+
90+
{% hint style="info" %}
91+
While `MediaWithCrops` is the default return type, `IPublishedContent` may be used in backward-compatible implementations or when working directly with core APIs.
92+
{% endhint %}
93+
7494
### Multiple enabled with Modelsbuilder
7595

7696
```csharp

14/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/media-picker-3.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

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

9-
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.
9+
This property editors returns one of the following:
10+
11+
- A collection (`IEnumerable<MediaWithCrops>`) if the **Pick multiple items** setting is enabled.
12+
- A single `MediaWithCrops` item if the **Pick multiple items** setting is disabled.
1013

1114
## Data Type Definition Example
1215

@@ -73,6 +76,23 @@ Global crops are configured on the Image Cropper property of the Image Media Typ
7376
}
7477
```
7578

79+
#### Multiple enabled without Modelsbuilder to retrieve IEnumerable<IPublishedContent> data
80+
81+
```csharp
82+
@using Umbraco.Cms.Core.Models
83+
@{
84+
var listOfImages = Model.Value<IEnumerable<IPublishedContent>>("medias");
85+
foreach (var image in listOfImages)
86+
{
87+
<img src="@image.Url()" alt="@image.Name" />
88+
}
89+
}
90+
```
91+
92+
{% hint style="info" %}
93+
While `MediaWithCrops` is the default return type, `IPublishedContent` may be used in backward-compatible implementations or when working directly with core APIs.
94+
{% endhint %}
95+
7696
### Multiple enabled with Modelsbuilder
7797

7898
```csharp

15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/media-picker-3.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

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

9-
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.
9+
This property editors returns one of the following:
10+
11+
- A collection (`IEnumerable<MediaWithCrops>`) if the **Pick multiple items** setting is enabled.
12+
- A single `MediaWithCrops` item if the **Pick multiple items** setting is disabled.
1013

1114
## Data Type Definition Example
1215

@@ -73,6 +76,23 @@ Global crops are configured on the Image Cropper property of the Image Media Typ
7376
}
7477
```
7578

79+
#### Multiple enabled without Modelsbuilder to retrieve IEnumerable<IPublishedContent> data
80+
81+
```csharp
82+
@using Umbraco.Cms.Core.Models
83+
@{
84+
var listOfImages = Model.Value<IEnumerable<IPublishedContent>>("medias");
85+
foreach (var image in listOfImages)
86+
{
87+
<img src="@image.Url()" alt="@image.Name" />
88+
}
89+
}
90+
```
91+
92+
{% hint style="info" %}
93+
While `MediaWithCrops` is the default return type, `IPublishedContent` may be used in backward-compatible implementations or when working directly with core APIs.
94+
{% endhint %}
95+
7696
### Multiple enabled with Modelsbuilder
7797

7898
```csharp

0 commit comments

Comments
 (0)