public static Attachment GetPostImage(AgilityContentItem blogConfig, AgilityContentItem post, PostImageType type) { string listingFieldName = "ListingImageOverride"; string detailsFieldName = "PostImage"; string defaultFieldName = "DefaultPostImage"; Attachment att = null; if (type.Equals(PostImageType.Listing)) { att = post.GetAttachment(listingFieldName); if (att == null) { att = post.GetAttachment(detailsFieldName); } } if (type.Equals(PostImageType.Details)) { att = post.GetAttachment(detailsFieldName); } if (att == null) { //try to get attachment from default image att = blogConfig.GetAttachment(defaultFieldName); } return(att); }
private static Attachment GetBlogPostListingImage(AgilityContentItem contentItem) { Attachment resultListingImage = null; if (contentItem != null) { var postImage = contentItem.GetAttachment("PostImage"); var listingImage = contentItem.GetAttachment("ListingImageOverride"); resultListingImage = postImage ?? resultListingImage; } return(resultListingImage); }
public static Attachment GetAuthorImage(AgilityContentItem blogConfig, AgilityContentItem author) { string authorFieldName = "Image"; string defaultFieldName = "DefaultAuthorImage"; Attachment att = null; att = author.GetAttachment(authorFieldName); if (att == null) { att = blogConfig.GetAttachment(defaultFieldName); } return(att); }
public static dynamic ToDynamic(this AgilityContentItem ci, bool removeHrefTilde = false) { var dynamicObj = new ExpandoObject() as IDictionary <string, Object>; DataColumnCollection columns = ci.Row.Table.Columns; //write each column into our dynamic obj foreach (var col in columns) { string colName = col.ToString(); var objValue = ci[colName]; //specific cases with a string if (objValue is string) { //have to test whether this is an attachment //TODO: need a more performant way to do this var attachment = ci.GetAttachment(colName); if (attachment != null) { objValue = attachment; } //test whether this is a UrlField else if (IsAnchorTag(objValue as string)) { if (removeHrefTilde) { objValue = ci.ParseUrl(colName).RemoveTilde(); } else { objValue = ci.ParseUrl(colName); } } } dynamicObj.Add(colName, objValue); } return(dynamicObj); }