Copied to clipboard

Flag this post as spam?

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


  • Mark Bennett 199 posts 375 karma points
    Oct 07, 2014 @ 15:04
    Mark Bennett
    0

    Issue with the Image.generated.cs when using the Model Builder

    Hi Jeroen,

    So i've listened to the uHangout a few times now and i'm having a bash at taking the bits I like and putting them into my own solution.

    I also find that this is a good way for me to really work out what is going on.

    So I'm trying to get the Image galleries working with my website. I have create an Image media type in the Umbraco back office the same as yours with the umbracoFile set to be a type of Image Cropper.

    I have my Umbraco Site and Umbraco Extensions projects inside my solution the same as in your example and I have the model builder running without error.

    However when it auto generates the umbracoFile PropertyType it isn't using the correct type:

    I know that you said on Twitter am I using the Hybrid Framework ? Did this mean that I should be using the PropertyConverters within your solution?

    How does the model builder know to push in a Umbraco.Web.Models.ImageCropDataSet rather than the Json type that I am getting?

    Grateful of your help :)

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Oct 07, 2014 @ 15:31
    Jeroen Breuer
    100

    Hello,

    The Models Builder uses the Property Value Converters to determine what kind of type the property needs to become. By default the Image Cropper doesn't have a property value converter so it goes through the default convert which sees that it's JSON and returns a JToken object for it. By adding the ImageCropperConverter.cs the Models Builder knows that for the Image Cropper it needs to convert to a ImageCropDataSet. After that the converter is also used to fill the ImageCropDataSet with the correct data when you call the property on the generated Image object.

    So you could use the converters of the Hybrid Framework if you want it to work the same.

    Jeroen

  • Mark Bennett 199 posts 375 karma points
    Oct 07, 2014 @ 16:38
    Mark Bennett
    0

    Hi,

    I sorted it - my Extensions weren't building due to me not having a doctype for Base and Website yet. So I had to comment out lots of stuff to get it to build - including the code in the AsValid method on the Image class.

    Then I added the reference to the extensions from the site and of course the Models Builder now uses the Property Value Converters and I have the correct ImageCropDataSet for my Cropper.

    Now I can add the AsValid back properly and move onto the next issue.

    Thanks for your help and thanks for creating the framework...learning lots of wonderful black magic with Umbraco 7 :)

    Mark.. 

Please Sign in or register to post replies

Write your reply to:

Draft