Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • William Even 23 posts 153 karma points
    Jan 31, 2020 @ 15:31
    William Even
    0

    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

  • Alex Skrypnyk 6182 posts 24284 karma points MVP 8x admin c-trib
    Feb 01, 2020 @ 00:00
    Alex Skrypnyk
    0

    Hi William

    Do you have cropp with "Grid" alias?

    Alex

  • William Even 23 posts 153 karma points
    Feb 04, 2020 @ 21:24
    William Even
    0

    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'

  • William Even 23 posts 153 karma points
    Feb 04, 2020 @ 21:28
    William Even
    0

    Hi Alex,

    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="?tag=@t.Text">@t.Text (@t.NodeCount)</a>
                }
            </nav>
        </div>
            </div>
    
        </div>
    
    
    </div>
    

  • Alex Skrypnyk 6182 posts 24284 karma points MVP 8x admin c-trib
    Feb 05, 2020 @ 11:20
    Alex Skrypnyk
    0

    Hi William

    Use this code:

    var cropUrl = article.GetCropUrl("Grid"); 
    
  • Alex Skrypnyk 6182 posts 24284 karma points MVP 8x admin c-trib
    Feb 06, 2020 @ 23:59
    Alex Skrypnyk
    0

    Hi William

    Let us know how it goes? Does it work?

    Alex

  • William Even 23 posts 153 karma points
    Feb 07, 2020 @ 14:31
    William Even
    100

    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

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies