Copied to clipboard

Flag this post as spam?

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


  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 22, 2013 @ 17:19
    Jeavon Leopold
    1

    Suggestion - include a Property Editor Value Converter

    Hi Dirk,

    Awesome work on this package! Have you considered including a property editor value converter for use with Mvc?

    You have even already included a Model for the crops so it should be really easy to implement.

    Thanks,

    Jeavon

  • Dirk Seefeld 126 posts 665 karma points
    Aug 22, 2013 @ 23:47
    Dirk Seefeld
    0

    Hi Jeavon,

    indeed it was easy to implement an PropertyEditorValueConverter, but that will break the model approach as I have documented :-(

    I guess I could make an extra package for the PropertyEditorValueConverter.

    Dirk

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 23, 2013 @ 00:38
    Jeavon Leopold
    0

    Hi Dirk,

    That is a dilemma, if you were to include a PEVC, what does it break in the currently documented approach?

    Jeavon

  • Dirk Seefeld 126 posts 665 karma points
    Aug 23, 2013 @ 08:27
    Dirk Seefeld
    1

    Hi Jeavon,

    meanwhile I have build and uploaded an addon package Image_Cropper_Extended_PEVC_1.0.zip. Thus all users who have implemented the "model" approach (see docu page 8 "MVC") may update to version 1.7 without breaking their views.
    All who prefer the PropertyEditorValueConverter - which indeed looks smarter -  can install the addon package (see docu page 8 "MVC" too).
    I think the problem is Model.Conten.GetPropertyValue<T>(). With the typed PropertyEditorValueConverterin place the result of  Model.Conten.GetPropertyValue<string>() does not return the xml content as string. I guess this is the same issue you mentioned in the context of integrating the PEVCs into core(?)

    What do you think, was my first "model" approach somehow awkward? Should I change to PEVC in the next version of the Image Cropper Extended package?

    Dirk

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 23, 2013 @ 12:51
    Jeavon Leopold
    0

    Hi Dirk,

    I've just been thinking about this, but I'm having trouble getting it working with the current model (without PEVC installed).

    Here's what I'm trying:

    var a = Umbraco.TypedMedia(1047);
    var b = a.GetPropertyValue<string>("crop");
    var c = new ImageCropperModel(b);
    

    Which gives me an exception:

    "System.NullReferenceException was unhandled by user code" on line NewUrl = crop.Attributes["newurl"].Value;

    var b contains <crops date=\"2013-08-23T09:26:38\" ignoreICC=\"false\"><crop name=\"thumb\" x=\"0\" y=\"0\" x2=\"768\" y2=\"768\" width=\"100\" height=\"100\" /></crops>

    Am I doing something stupid?

    Thanks,

    Jeavon

  • Dirk Seefeld 126 posts 665 karma points
    Aug 23, 2013 @ 14:10
    Dirk Seefeld
    0

    Hi Jeavon,

    you are almost right;-) The first three lines are fine:

    var a = Umbraco.TypedMedia(1047);
    var b = a.GetPropertyValue<string>("crop");
    var c = new ImageCropperModel(b);

    but line NewUrl = crop.Attributes["newurl"].Value; does not work. Var c is a strongly typed object with InteliSense in VStudio (what helps a lot!). Thus you can do this to select a certain crop:

    var thumbCrop = c.Find("thumb");
    var newUrl = thumbCrop.NewUrl;
    var altText = thumbCrop.Name;
    <img src="@newUrl" alt="@altText"/>

    or if you want to iterate over all definded crops of the cropper property do the following:

    @foreach (var crop in c.Crops){  @crop.Name <br /><img src="@crop.NewUrl" alt="@crop.Name"/> }

    I hope, this is helpful(?)

    Your,
    Dirk

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 23, 2013 @ 15:44
    Jeavon Leopold
    1

    Hi Dirk,

    Line 3 throws the exception, and while debug shows the exception is caused by NewUrl = crop.Attributes["newurl"].Value;

    Thanks,

    Jeavon

  • Dirk Seefeld 126 posts 665 karma points
    Aug 23, 2013 @ 16:40
    Dirk Seefeld
    0

    Well, I got it!

    Please check the Save crop images as files: in the data type settings. Thus crop images will be rendered.

    Meanwhile I will fix the bug in the model...

    Dirk

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 23, 2013 @ 17:11
    Jeavon Leopold
    0

    Ah great, glad I'm not completely stupid then :-)

  • Dirk Seefeld 126 posts 665 karma points
    Aug 23, 2013 @ 17:25
    Dirk Seefeld
    0

    No, you are not, but I am the one, who has to admit his failure. What was it that Alex calls it? Not HY5r but ...

  • Dirk Seefeld 126 posts 665 karma points
    Aug 23, 2013 @ 17:53
    Dirk Seefeld
    0

    Bug killed! :-D

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 23, 2013 @ 18:26
    Jeavon Leopold
    0

    Ah cool, looks like you've switched to including the PEVC in the package also.

    This package definitely deserves a h5yr not a h5is!

    Great work!

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 23, 2013 @ 23:38
    Jeavon Leopold
    1

    Hey Dirk,

    Did you get the PEVC working with TypedMedia? I have it working with TypedContent but not TypedMedia, I don't think I've actually every tried a PEVC with TypeMedia before so maybe there is a core bug....? e.g

    var a = Umbraco.TypedMedia(1047);
    var b = a.GetPropertyValue<CropList>("crop");
    

    Thanks,

    Jeavon

  • Dirk Seefeld 126 posts 665 karma points
    Aug 24, 2013 @ 07:53
    Dirk Seefeld
    0

    Hey Jeavon,

    I guess you are right there seems to be a bug in the core. As far as I have analysed, the data type GUID is not properly detected in the media context.
    I shall dig deep and have a look at the issues list.

    Please have a look at the sample partial views (SamplePartialViews_4_Image_Cropper_Extended_2.0.2.zip) that I have attached to this project. It's only a little bit more clunky instead of

    mediaItem.GetPropertyValue<CropList>("crops")

    you have 

    new idseefeld.de.imagecropper.Model.ImageCropperModel(mediaItem.GetPropertyValue<string>("crops"))
    

     But of course a strongly typed PEVC for media would be much more consistent and transparent. So I will see what I can do.

    Many Thanks for your testing and reports!
    This really makes me happy and lets me forget all the hours of coding - just have to convince my wife of this value ;-)

    Dirk

     

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 24, 2013 @ 10:05
    Jeavon Leopold
    1

    Hi Dirk,

    I have confirmed that it is indeed a bug and reported it here http://issues.umbraco.org/issue/U4-2713

    Jeavon

  • Dirk Seefeld 126 posts 665 karma points
    Aug 24, 2013 @ 10:55
    Dirk Seefeld
    0

    Hi Jeavon,

    great, meanwhile I figured out a posible solution and added my proposal to the issue.
    Lets see waht core team thinks. It seems quit complex...

    Dirk

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Sep 02, 2013 @ 17:21
    Jeavon Leopold
    0

    Hi Dirk,

    Have you given it a try with a v6.2 nightly yet?

    Jeavon

  • Dirk Seefeld 126 posts 665 karma points
    Sep 02, 2013 @ 19:59
    Dirk Seefeld
    100

    Hi Jeavon,

    I have just tried v6.2 and it works. In principle Shannon has implemented my suggestion with some optimisation ;-)

    Dirk

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Sep 02, 2013 @ 20:01
    Jeavon Leopold
    0

    Awesome job all round then!

Please Sign in or register to post replies

Write your reply to:

Draft