Skip to content

Commit 72a3ace

Browse files
authored
Merge pull request #57 from umbraco/feature/zapier-mediacropurl
Get URL for media content types
2 parents 0f4491a + cb75629 commit 72a3ace

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

src/Umbraco.Cms.Integrations.Automation.Zapier/Extensions/ContentExtensions.cs

+24-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
#if NETCOREAPP
66
using Umbraco.Cms.Core.Models;
77
using Umbraco.Cms.Core.Models.PublishedContent;
8+
using Umbraco.Extensions;
89
#else
910
using Umbraco.Core.Models;
1011
using Umbraco.Core.Models.PublishedContent;
12+
using Umbraco.Web;
1113
#endif
1214

1315
namespace Umbraco.Cms.Integrations.Automation.Zapier.Extensions
@@ -33,7 +35,10 @@ public static Dictionary<string, string> ToContentTypeDictionary(this IContentTy
3335

3436
var contentProperty = content.Properties.First(p => p.Alias == propertyType.Alias);
3537

36-
contentDict.Add(propertyType.Alias, contentProperty.GetValue().ToString());
38+
if(IsMedia(contentProperty, out string url))
39+
contentDict.Add(propertyType.Alias, url);
40+
else
41+
contentDict.Add(propertyType.Alias, contentProperty.GetValue().ToString());
3742
}
3843

3944
return contentDict;
@@ -55,5 +60,23 @@ public static Dictionary<string, string> ToContentDictionary(this IContent conte
5560

5661
return contentDict;
5762
}
63+
64+
private static bool IsMedia(IPublishedProperty contentProperty, out string url)
65+
{
66+
switch (contentProperty.PropertyType.EditorAlias)
67+
{
68+
case Core.Constants.PropertyEditors.Aliases.MediaPicker:
69+
var mediaPickerValue = contentProperty.GetValue() as IPublishedContent;
70+
url = mediaPickerValue.Url();
71+
return true;
72+
case Core.Constants.PropertyEditors.Aliases.MediaPicker3:
73+
var mediaPicker3Value = contentProperty.GetValue() as MediaWithCrops;
74+
url = mediaPicker3Value.LocalCrops.Src;
75+
return true;
76+
default:
77+
url = string.Empty;
78+
return false;
79+
}
80+
}
5881
}
5982
}

src/Umbraco.Cms.Integrations.Automation.Zapier/Umbraco.Cms.Integrations.Automation.Zapier.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
<RepositoryUrl>https://github.com/umbraco/Umbraco.Cms.Integrations</RepositoryUrl>
1010
<PackageProjectUrl>https://github.com/umbraco/Umbraco.Cms.Integrations/blob/main/src/Umbraco.Cms.Integrations.Automation.Zapier</PackageProjectUrl>
1111
<Product>Umbraco.Cms.Integrations.Automation.Zapier</Product>
12-
<Version>1.0.4</Version>
12+
<Version>1.1.0</Version>
1313
<PackageTags>Umbraco;Umbraco-Marketplace</PackageTags>
1414
</PropertyGroup>
1515

1616
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
17-
<PackageReference Include="UmbracoCms.Web" Version="8.5.4" />
17+
<PackageReference Include="UmbracoCms.Web" Version="8.14.0" />
1818
</ItemGroup>
1919

2020
<ItemGroup Condition="'$(TargetFramework)' == 'net50'">

src/Umbraco.Cms.Integrations.Automation.Zapier/package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<info>
44
<package>
55
<name>Umbraco.Cms.Integrations.Automation.Zapier</name>
6-
<version>1.0.4</version>
6+
<version>1.1.0</version>
77
<iconUrl></iconUrl>
88
<licence url="https://opensource.org/licenses/MIT">MIT</licence>
99
<url>https://github.com/umbraco/Umbraco.Cms.Integrations</url>

0 commit comments

Comments
 (0)