Copied to clipboard

Flag this post as spam?

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


  • Danny Winbourne 12 posts 63 karma points
    Jun 17, 2021 @ 10:53
    Danny Winbourne
    0

    MediaWithCrops Model missing?

    I have created a simple element type, with a media picker property. The auto generated model class generates the below

            ///<summary>
        /// Main Image
        ///</summary>
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "8.14.0")]
        [ImplementPropertyType("mainImage")]
        public virtual global::Umbraco.Core.Models.MediaWithCrops MainImage => this.Value<global::Umbraco.Core.Models.MediaWithCrops>("mainImage");
    

    I am however getting a compilation error as it is telling me that "MediaWithCrops " does not exist..

    As file is autogeneated and updates as new fields are added I am getting I shouldn't be adding in an extra using. Can anyone suggest what I am missing please?

    I get same generated code if I use Image Picker of Media Picker? Am I maybe using the wrong control for selecting images?

  • Danny Winbourne 12 posts 63 karma points
    Jun 17, 2021 @ 11:08
    Danny Winbourne
    0

    Fixed - my .Core project had a different version referenced.

  • Nastaran 1 post 20 karma points
    Jun 28, 2021 @ 06:51
    Nastaran
    0

    Hi Danny, I'm getting the same error for MediaWithCrops. May I please ask how you fixed it?

  • Damien Holley 179 posts 540 karma points
    Sep 06, 2021 @ 10:42
    Damien Holley
    0

    Example?

  • David Zweben 266 posts 750 karma points
    Mar 01, 2022 @ 18:49
    David Zweben
    0

    I am also having this problem. It is an Umbraco Cloud local site with .Web and .Core projects. References to Umbraco.Core.Models.MediaWithCrops work as expected in the Core project, but in the Web project I can't get Visual Studio to see the class.

    I have tried removing references to Umbraco.Core under Dependencies > Assembles in the Core project, and adding the DLL under Add Assembly Reference and selecting the DLL file under the .Core project directory > Bin > Umbraco.Core.dll, but it doesn't change anything.

    When I pull up the Properties on the Umbraco.Core reference in my Core project, it shows as version 8.0.0.0, which is the same version that comes up if I hit F12 on a MediaWithCrops reference in the Web project.

    Can anyone suggest anything to try? I'm stumped, and currently unable to use the current version of the Media Picker at all.

  • David Zweben 266 posts 750 karma points
    Mar 01, 2022 @ 20:36
    David Zweben
    0

    I figured it out in my case. My .Core project had a package reference to an ancient version of UmbracoCms.Web. Once I updated this, it worked properly.

    In the Core project's .csproj file, this was the old line:

    <PackageReference Include="UmbracoCms.Web" Version="8.1.0" />
    

    Updating it to match the current Umbraco version via NuGet fixed the issue:

    <PackageReference Include="UmbracoCms.Web" Version="8.17.2" />
    

    It's probably best not to reference the package this way, but removing it broke a lot of stuff, so we'll just update it like shown.

  • sther 2 posts 71 karma points
    Mar 02, 2022 @ 12:11
    sther
    0

    RobertFoster Im using something similar but I cant get it to work. Im getting the below error on Umbraco.Media :- System.NullReferenceException: Object reference not set to an instance of an object. at Umbraco.Web.PublishedContentExtensions.Url(IPublishedContent content, String culture, UrlMode mode) in D:\a\1\s\src\Umbraco.Web\PublishedContentExtensions.cs:line 1436 at

Please Sign in or register to post replies

Write your reply to:

Draft