public IEnterspeedProperty Convert(Item item, Field field, EnterspeedSiteInfo siteInfo, List <IEnterspeedFieldValueConverter> fieldValueConverters) { FileField fileField = field; if (fileField?.MediaItem == null) { return(null); } string mediaUrl = _urlService.GetMediaUrl(fileField.MediaItem); if (string.IsNullOrEmpty(mediaUrl)) { return(null); } return(new StringEnterspeedProperty(_fieldService.GetFieldName(field), mediaUrl)); }
public IEnterspeedProperty Convert(Item item, Field field, EnterspeedSiteInfo siteInfo, List <IEnterspeedFieldValueConverter> fieldValueConverters) { LinkField linkField = field; if (linkField == null) { return(null); } var properties = new Dictionary <string, IEnterspeedProperty>(); if (!string.IsNullOrEmpty(linkField.Target)) { properties.Add(PropertyTarget, new StringEnterspeedProperty(PropertyTarget, linkField.Target)); } if (!string.IsNullOrEmpty(linkField.Anchor)) { properties.Add(PropertyAnchor, new StringEnterspeedProperty(PropertyAnchor, linkField.Anchor)); } if (!string.IsNullOrEmpty(linkField.Text)) { properties.Add(PropertyText, new StringEnterspeedProperty(PropertyText, linkField.Text)); } if (!string.IsNullOrEmpty(linkField.Title)) { properties.Add(PropertyTitle, new StringEnterspeedProperty(PropertyTitle, linkField.Title)); } if (!string.IsNullOrEmpty(linkField.Class)) { properties.Add(PropertyClass, new StringEnterspeedProperty(PropertyClass, linkField.Class)); } string url = null; if (linkField.LinkType == "media") { url = _urlService.GetMediaUrl(linkField.TargetItem); } else if (linkField.LinkType == "internal") { url = _urlService.GetItemUrl(linkField.TargetItem); if (linkField.TargetItem != null) { properties.Add(PropertyTargetType, new StringEnterspeedProperty(PropertyTargetType, linkField.TargetItem.TemplateName)); properties.Add(PropertyTargetId, new StringEnterspeedProperty(PropertyTargetId, _enterspeedIdentityService.GetId(linkField.TargetItem))); } } else if (linkField.LinkType == "external" || linkField.LinkType == "anchor" || linkField.LinkType == "mailto" || linkField.LinkType == "javascript") { url = linkField.GetFriendlyUrl(); } if (!string.IsNullOrEmpty(url)) { properties.Add(PropertyUrl, new StringEnterspeedProperty(PropertyUrl, url)); } else { return(null); } return(new ObjectEnterspeedProperty(_fieldService.GetFieldName(field), properties)); }