/// <summary> /// Renders an image allowing simple page editor support /// </summary> /// <typeparam name="T">The model type</typeparam> /// <param name="model">The model that contains the image field</param> /// <param name="field">A lambda expression to the image field, should be of type Glass.Mapper.Sc.Fields.Image</param> /// <param name="parameters">Image parameters, e.g. width, height</param> /// <param name="isEditable">Indicates if the field should be editable</param> /// <returns></returns> public virtual RawString RenderImage <T>(T model, Expression <Func <T, object> > field, object parameters = null, bool isEditable = false) { return(_glassHtml.RenderImage(model, field, parameters, isEditable).RawString()); }
public BlogViewModel ConvertTo(IBlog blog, bool isFeaturedArticle) { return(new BlogViewModel { BlogId = blog.Id.ToString(), Title = new HtmlString(_glassHtml.Editable(blog, item => item.Title)), Intro = new HtmlString(_glassHtml.Editable(blog, item => item.Intro)), Description = new HtmlString(_glassHtml.Editable(blog, item => item.Description)), BlogImage = isFeaturedArticle ? new HtmlString(_glassHtml.RenderImage(blog, item => item.FeatureImage, new { @class = Constants.BlogImageClassName })) : new HtmlString(_glassHtml.RenderImage(blog, item => item.LandingBoxImage, new { @class = Constants.BlogImageWithFluidClassName })), BlogCreated = blog.BlogCreated, AuthorFirstName = blog.Author != null ? new HtmlString(_glassHtml.Editable(blog, item => item.Author.FirstName)) : null, AuthorLastName = blog.Author != null ? new HtmlString(_glassHtml.Editable(blog, item => item.Author.LastName)) : null, AuthorImage = blog.Author != null ? new HtmlString(_glassHtml.RenderImage(blog, item => item.Author.Image, new { @class = isFeaturedArticle ? Constants.AuthorImageClassName : Constants.ImageFluidClassName })) : null, AuthorDescription = blog.Author != null ? new HtmlString(_glassHtml.Editable(blog, item => item.Author.AuthorSummary)) : null, BlogUrl = blog.Url, CommentCount = _commentService.GetCommentsCount(blog.Id.ToString()) }); }
public BlogDetailViewModel ConvertTo(IBlog blog, bool isFeaturedArticle = false) { return(new BlogDetailViewModel { Title = new HtmlString(_glassHtml.Editable(blog, item => item.Title)), Intro = new HtmlString(_glassHtml.Editable(blog, item => item.Intro)), Description = new HtmlString(_glassHtml.Editable(blog, item => item.Description)), BlogImage = new HtmlString(_glassHtml.RenderImage(blog, item => item.HeroImage)), BlogCreated = blog.BlogCreated }); }
private RecommendedCardViewModel MapRecommendedItemToRecommendedCardViewModel(IRecommendedCard card) { var recommendedCardViewModel = new RecommendedCardViewModel(); recommendedCardViewModel.Title = new HtmlString(_glassHtml.Editable(card, i => i.Title)); recommendedCardViewModel.Body = new HtmlString(_glassHtml.Editable(card, i => i.Body)); recommendedCardViewModel.Image = new HtmlString(_glassHtml.RenderImage(card, i => i.Image, isEditable: true)); recommendedCardViewModel.CallToActionLink = new HtmlString(_glassHtml.RenderLink(card, i => i.CallToAction)); recommendedCardViewModel.Url = card.CallToAction?.Url; return(recommendedCardViewModel); }
public HtmlString BuildImage <TModel>(TModel contentItem, Expression <Func <TModel, object> > field) where TModel : IContentBase { var newString = _glassHtml.RenderImage(contentItem, field); return(new HtmlString(newString)); }
/// <summary> /// Renders the image. /// </summary> /// <param name="image">The image.</param> /// <returns>RawString.</returns> public RawString RenderImage(Image image) { return(_glassHtml.RenderImage(image).RawString()); }