-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added extension method to get the icon from an PublishedContentType
This is particularly helpful (to me) when using the RenderMacro editor.
- Loading branch information
1 parent
1421e3e
commit 94b3b1f
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/Umbraco.Community.Contentment/Web/Extensions/PublishedContentTypeExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* Copyright © 2021 Lee Kelleher. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
using Umbraco.Community.Contentment.DataEditors; | ||
using Umbraco.Core.Models.PublishedContent; | ||
using Umbraco.Core.Services; | ||
using UmbConstants = Umbraco.Core.Constants; | ||
|
||
namespace Umbraco.Web | ||
{ | ||
public static class PublishedContentTypeExtensions | ||
{ | ||
public static string GetIcon(this IPublishedContentType contentType, IContentTypeService contentTypeService = null) | ||
{ | ||
if (contentType != null && ContentTypeCacheHelper.TryGetIcon(contentType.Alias, out var icon, contentTypeService) == true) | ||
{ | ||
return icon; | ||
} | ||
|
||
return UmbConstants.Icons.DefaultIcon; | ||
} | ||
} | ||
} |