public static PublicLinkData GetPublicLinkData(string host, IEntity asset, IEntity publicLink, string rendition) { var publicLinkData = new PublicLinkData() { AssetId = asset.Id.Value.ToString() }; var relativeUrl = publicLink.GetPropertyValue(Constants.PublicLink.Properties.RelativeUrl); var version = publicLink.GetPropertyValue(Constants.PublicLink.Properties.VersionHash); publicLinkData.URL = $"{host}/api/public/content/{relativeUrl}?v={version}"; publicLinkData.AltText = asset.GetPropertyValue <string>(Constants.Asset.Properties.Title) ?? asset.GetPropertyValue <string>(Constants.Asset.Properties.FileName); var publicLinkConversions = publicLink.GetPropertyValue <JToken>(Constants.PublicLink.Properties.ConversionConfiguration); JToken imageProperties = null; if (publicLinkConversions != null) { imageProperties = publicLinkConversions; } else //no custom dimensions set. get dimension from rendition { var renditions = asset.GetPropertyValue <JToken>(Constants.Asset.Properties.Renditions); if (renditions != null) { var renditionProperties = renditions.SelectToken($"{rendition.ToLowerInvariant()}.properties"); if (renditionProperties != null) { imageProperties = renditionProperties; } } } var width = imageProperties.SelectToken("width"); if (width != null) { publicLinkData.Width = width.ToObject <string>(); } var height = imageProperties.SelectToken("height"); if (height != null) { publicLinkData.Height = height.ToObject <string>(); } return(publicLinkData); }
private string GetContentHubDamImageElement(string host, PublicLinkData publicLink) { return($"<image stylelabs-content-id=\"{publicLink.AssetId}\" thumbnailsrc=\"{host}/api/gateway/{publicLink.AssetId}/thumbnail\" src=\"{publicLink.URL}\" mediaid =\"\" stylelabs-content-type=\"{publicLink.ContentType.ToString()}\" alt=\"{publicLink.AltText}\" height=\"{publicLink.Height}\" width=\"{publicLink.Width}\" />"); }