File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
src/Umbraco.Cms.Integrations.DAM.Aprimo Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -12,14 +12,35 @@ public class AprimoMediaWithCropsViewModel
12
12
/// </summary>
13
13
/// <param name="name"></param>
14
14
/// <returns>Crop URL</returns>
15
- public string GetImageUrl ( string name )
15
+ public string GetCropUrl ( string name )
16
16
{
17
17
var crop = Crops . FirstOrDefault ( p => p . Name == name ) ;
18
18
if ( crop != null )
19
19
return crop . Url ;
20
20
21
21
return string . Empty ;
22
22
}
23
+
24
+ /// <summary>
25
+ /// Get image URL by size
26
+ /// </summary>
27
+ /// <param name="name"></param>
28
+ /// <returns>Crop URL</returns>
29
+ public string GetCropUrl ( int ? width , int ? height )
30
+ {
31
+ if ( ! width . HasValue && ! height . HasValue )
32
+ throw new ArgumentException ( "Width and height cannot be both NULL." ) ;
33
+
34
+ var crop = width . HasValue && height . HasValue
35
+ ? Crops . FirstOrDefault ( p => p . ResizeWidth == width && p . ResizeHeight == height )
36
+ : ( width . HasValue
37
+ ? Crops . FirstOrDefault ( p => p . ResizeWidth == width )
38
+ : Crops . FirstOrDefault ( p => p . ResizeHeight == height ) ) ;
39
+ if ( crop != null )
40
+ return crop . Url ;
41
+
42
+ return string . Empty ;
43
+ }
23
44
}
24
45
25
46
public class AprimoMediaItemViewModel
Original file line number Diff line number Diff line change @@ -76,4 +76,12 @@ Properties available from the strongly-typed model:
76
76
- Title
77
77
- Thumbnail
78
78
- Crops
79
- - Asset fields
79
+ - Asset fields
80
+
81
+ ### Working with Crops
82
+ For the selected media asset you can retrieve the crops details using the ` MediaWithCrops ` object.
83
+
84
+ It contains the details of the original asset, the list of available crops and a method to retrieve the crop URL based on name and width/height.
85
+
86
+ ### Working with fields
87
+ The asset's fields are grouped in an object containing their label and a dictionary of values based on the available cultures for that asset.
You can’t perform that action at this time.
0 commit comments