Copied to clipboard

Flag this post as spam?

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


  • Kris 14 posts 96 karma points
    Oct 15, 2018 @ 17:00
    Kris
    0

    The name 'ImageCropMode' does not exist in the current context

    I am having issues trying to Set the crop mode. I am using:

    @item.HeaderImage.GetCropUrl(1140,568,imageCropMode: ImageCropMode.Crop)
    

    I have also tried:

    @Url.GetCropUrl(item.HeaderImage, 1140, 568, imageCropMode: ImageCropMode.Crop)
    

    I keep getting this error:

    Compiler Error Message: CS0103: The name 'ImageCropMode' does not exist in the current context

    What am I doing wrong here?

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Oct 15, 2018 @ 17:27
    Alex Skrypnyk
    100

    Hi Kris

    Add to the top of the document:

    @using Umbraco.Web.Models
    

    Thanks,

    Alex

  • Kris 14 posts 96 karma points
    Oct 15, 2018 @ 17:38
    Kris
    0

    Is there a way to do this globally? like in the web.config?

  • Kris 14 posts 96 karma points
    Oct 15, 2018 @ 17:43
    Kris
    1
    <add namespace="Umbraco.Core.Models" />
    

    Add that to /Views/Web.config in this section

    <system.web.webPages.razor>
            <pages pageBaseType="System.Web.Mvc.WebViewPage">
                <namespaces>
    
Please Sign in or register to post replies

Write your reply to:

Draft