/// <summary> /// Get a video from the given item. /// </summary> /// <param name="item">The item.</param> /// <param name="fieldName">Name of the field.</param> /// <returns> /// The video. /// </returns> public static VideoModel GetVideo(this ContentModel item, string fieldName) { if (item == null || !item.DoesFieldExist(fieldName)) { return(null); } Video sfContent = item.GetOriginal().GetRelatedItems <Video>(fieldName).FirstOrDefault(); return(sfContent != null ? new VideoModel(sfContent) : null); }
/// <summary> /// Get a single image from a content. /// </summary> /// <param name="item">The item.</param> /// <param name="fieldName">Name of the field.</param> /// <returns> /// Telerik.Sitefinity.Libraries.Model.Image object. /// </returns> public static DocumentModel GetDocument(this ContentModel item, string fieldName) { if (!item.DoesFieldExist(fieldName)) { return(null); } var sfContent = item.GetOriginal().GetRelatedItems <Document>(fieldName).FirstOrDefault(); return(sfContent != null ? new DocumentModel(sfContent) : null); }
/// <summary> /// Get a single image from a content. /// </summary> /// <param name="item">The item.</param> /// <param name="fieldName">Name of the field.</param> /// <returns> /// The image. /// </returns> public static ImageModel GetImage(this ContentModel item, string fieldName) { //VALIDATE INPUT if (!item.DoesFieldExist(fieldName)) { return(null); } var sfContent = item.GetOriginal().GetRelatedItems <Image>(fieldName).FirstOrDefault(); return(sfContent != null ? new ImageModel(sfContent) : null); }
/// <summary> /// Gets the images collection from content. /// </summary> /// <param name="item">The item.</param> /// <param name="fieldName">Name of the field.</param> /// <returns> /// IQueryable Telerik.Sitefinity.Libraries.Model.Image. /// </returns> public static List <DocumentModel> GetDocuments(this ContentModel item, string fieldName) { return(item.DoesFieldExist(fieldName) ? item.GetOriginal().GetRelatedItems <Document>(fieldName).Select(x => new DocumentModel(x)).ToList() : Enumerable.Empty <DocumentModel>().ToList()); }