hey guys,
following scenario:
- defined an Umbraco.ImageCropper data field.
- defined a crop with the alias "hero", 1600 x 620
- uploaded an image, using the crop "hero"
within my home view I'm trying to pass the crop url to the partial view:
@inherits Umbraco.Web.Mvc.UmbracoViewPage<Home>
@using ProFinder.Core.ViewModels
@{
Layout = "master.cshtml";
}
@Html.Partial("~/Views/Partials/header.cshtml", new HeaderViewModel(Model.Name, Model.Title, Model.Subtitle, Model.MainImage.GetCropUrl("hero")))
Model.MainImage is an "ImageCropperValue" within the namespace Umbraco.Core.PropertyEditors.ValueConverters
My ViewModell:
public class HeaderViewModel
{
public string Name { get; set; }
public string Title { get; set; }
public string Subtitle { get; set; }
public bool HasSubtitle => !string.IsNullOrWhiteSpace(Subtitle);
public string BackgroundImageUrl { get; set; }
public bool HasBackgroundImage => string.IsNullOrEmpty(BackgroundImageUrl);
public string AuthorName { get; set; }
public bool HasAuthor => !string.IsNullOrWhiteSpace(AuthorName);
public DateTime? ArticleDate { get; set; }
public bool IsArticle => ArticleDate.HasValue;
public HeaderViewModel(string name, string title,
string subtitle, string backgroundImageUrl,
string authorName = null, DateTime? articleDate = null)
{
Name = name;
Title = title;
Subtitle = subtitle;
BackgroundImageUrl = backgroundImageUrl;
AuthorName = authorName;
ArticleDate = articleDate;
}
}
My PartialView:
@inherits UmbracoViewPage<ProFinder.Core.ViewModels.HeaderViewModel>
@{
string mainImageUrl = Model.HasBackgroundImage ? Model.BackgroundImageUrl : "img/home_section_1.jpg";
}
...
<section class="hero_single version_1" style="background-image: url('@mainImageUrl')">
Returned Url in response:
<section class="hero_single version_1" style="background-image: url('?center=0.41466666666666668,0.11833333333333333&mode=crop&width=1600&height=620')">
Which is not showing up the image.
Any ideas?
Thanks
Dee