Last active
November 8, 2016 12:31
-
-
Save Jeavon/9bcb59f02523e75a620f to your computer and use it in GitHub Desktop.
AppIcons - Partial View for Umbraco
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
@using Umbraco.Web.Models | |
@inherits UmbracoViewPage<IPublishedContent> | |
@{ | |
var internalMediaFolder = Umbraco.TypedMediaAtRoot().FirstOrDefault(x => x.DocumentTypeAlias == "InternalMediaFolder"); | |
if (internalMediaFolder != null) | |
{ | |
var appleTouchIcon = internalMediaFolder.Descendants().FirstOrDefault(x => x.DocumentTypeAlias == "AppleTouchIcon"); | |
if (appleTouchIcon != null) | |
{ | |
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="@appleTouchIcon.GetCropUrl(152, 152)" /> | |
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="@appleTouchIcon.GetCropUrl(144, 144)" /> | |
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="@appleTouchIcon.GetCropUrl(120, 120)" /> | |
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="@appleTouchIcon.GetCropUrl(114, 114)" /> | |
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="@appleTouchIcon.GetCropUrl(76, 76)" /> | |
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="@appleTouchIcon.GetCropUrl(72, 72)" /> | |
<link rel="apple-touch-icon-precomposed" href="@appleTouchIcon.GetCropUrl(57, 57)" /> | |
} | |
var microsoftTileIcon = internalMediaFolder.Descendants().FirstOrDefault(x => x.DocumentTypeAlias == "MicrosoftTileIcon"); | |
if (microsoftTileIcon != null) | |
{ | |
<meta name="msapplication-TileColor" content="#000"/> | |
<meta name="msapplication-square70x70logo" content="@microsoftTileIcon.GetCropUrl(70, 70)"/> | |
<meta name="msapplication-square150x150logo" content="@microsoftTileIcon.GetCropUrl(150, 150)"/> | |
<meta name="msapplication-wide310x150logo" content="@microsoftTileIcon.GetCropUrl(310, 150, imageCropMode: ImageCropMode.Pad)"/> | |
<meta name="msapplication-square310x310logo" content="@microsoftTileIcon.GetCropUrl(310, 310)"/> | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use this as is, create the following media types with no additional properties:
InternalMediaFolder - inherit from Folder
AppleTouchIcon - inherit from Image (assuming umbracoFile is a Image Cropper, not Upload!)
MicrosoftTileIcon - inherit from Image (assuming umbracoFile is a Image Cropper, not Upload!)
Allow AppleTouchIcon & MicrosoftTileIcon to be created under InternalMediaFolder
Create a "Internal" folder at root Media level and then create the Apple Touch Icon and Microsoft Tile Icons, either directly in the folder or organise how you like