Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm following through the Umbraco 8 Foundations class workbook and I'm encountering some issues.
Summary - Exercise 6, page 36: I created 3 crop sizes as per book and attempted to render images using the following code:
@if (article.Image != null) { var cropUrl = Url.GetCropUrl(article.Image, "Grid", false);
Nothing is displayed. I have been following the book to the letter. The images are there and display properly without the image cropper using style="background-image: url('@article.Image.Url')"
Thanks for the assistance. Bill Even CTG
Hi William
Do you have cropp with "Grid" alias?
Alex
Hi Alex,
Yes, I have the crop "Grid" set up. Now I am getting this compiler error:
CS1929: 'UrlHelper' does not contain a definition for 'GetCropUrl'
Here's the template code:
@inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.NewsArea>
@using ContentModels = Umbraco.Web.PublishedModels; @{ Layout = "childPage.cshtml"; var tag = Request.QueryString["tag"];
var articles = (tag != null) ? Umbraco.TagQuery.GetContentByTag(tag).OfType<NewsArticle>() :Model .Children<NewsArticle>() .OrderByDescending(x => x.CreateDate); var tags = Umbraco.TagQuery.GetAllTags();
}
<div class="container"> <div class="col-md-9"> <div class="container"> <!-- Start of news article listing --> <div class="articles col-md-9"> @foreach (var article in articles) { <a href="@article.Url" class="article article-with-image"> <div class="article-info"> <div class="article-meta"> <small class="article-date">@article.CreateDate</small> <small class="article-cat"> @String.Join(", ", article.Categories) </small> </div> <h3 class=article-title>@article.Name</h3> <div class="article-excerpt">@article.Summary</div> </div> @if (article.Image != null) { var cropUrl = Url.GetCropUrl(article.Image, "Grid", false); <div class="article-image" style="background-image: url('@cropUrl')"></div> } </a> } </div> <!-- End of news article listing --> <div class="col-md-3"> <h4>Categories:</h4> <nav class="nav-bar nav-bar--list"> @foreach (var t in tags) { <a class="nav-link nav-link--black nav-link--air-bottom" href="[email protected]">@t.Text (@t.NodeCount)</a> } </nav> </div> </div> </div> </div>
Use this code:
var cropUrl = article.GetCropUrl("Grid");
Let us know how it goes? Does it work?
Hi Alex. No, that didn't work either. I'm trying a different tutorial and working through it to see if I missed something fundamental.
Thanks, Bill
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Image Cropper (GetCropUrl) issues
I'm following through the Umbraco 8 Foundations class workbook and I'm encountering some issues.
Summary - Exercise 6, page 36: I created 3 crop sizes as per book and attempted to render images using the following code:
@if (article.Image != null) { var cropUrl = Url.GetCropUrl(article.Image, "Grid", false);
Nothing is displayed. I have been following the book to the letter. The images are there and display properly without the image cropper using style="background-image: url('@article.Image.Url')"
Thanks for the assistance. Bill Even CTG
Hi William
Do you have cropp with "Grid" alias?
Alex
Hi Alex,
Yes, I have the crop "Grid" set up. Now I am getting this compiler error:
CS1929: 'UrlHelper' does not contain a definition for 'GetCropUrl'
Hi Alex,
Here's the template code:
@using ContentModels = Umbraco.Web.PublishedModels; @{ Layout = "childPage.cshtml"; var tag = Request.QueryString["tag"];
}
Hi William
Use this code:
Hi William
Let us know how it goes? Does it work?
Alex
Hi Alex. No, that didn't work either. I'm trying a different tutorial and working through it to see if I missed something fundamental.
Thanks, Bill
is working on a reply...