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?
you are almost right;-) The first three lines are fine:
var a = Umbraco.TypedMedia(1047);
var b = a.GetPropertyValue<string>("crop");
var c = newImageCropperModel(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;
<imgsrc="@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 /><imgsrc="@crop.NewUrl"alt="@crop.Name"/> }
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");
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.
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 ;-)
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
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
Hi Dirk,
That is a dilemma, if you were to include a PEVC, what does it break in the currently documented approach?
Jeavon
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
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:
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
Hi Jeavon,
you are almost right;-) The first three lines are fine:
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:or if you want to iterate over all definded crops of the cropper property do the following:
I hope, this is helpful(?)
Your,
Dirk
Hi Dirk,
Line 3 throws the exception, and while debug shows the exception is caused by
NewUrl = crop.Attributes["newurl"].Value;
Thanks,
Jeavon
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
Ah great, glad I'm not completely stupid then :-)
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 ...
Bug killed! :-D
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!
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
Thanks,
Jeavon
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
you have
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
Hi Dirk,
I have confirmed that it is indeed a bug and reported it here http://issues.umbraco.org/issue/U4-2713
Jeavon
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
Hi Dirk,
Have you given it a try with a v6.2 nightly yet?
Jeavon
Hi Jeavon,
I have just tried v6.2 and it works. In principle Shannon has implemented my suggestion with some optimisation ;-)
Dirk
Awesome job all round then!
is working on a reply...