Ok, so heres a noob question. Just getting into the 7 way of things coming from the xslt world of previous versions trying to get to grips with razor, so bear with me :)
Im trying to render a series of images cropped with the new cropper and chosen with the new multi media picker.
Using:
@if(Model.Content.HasValue("caseStudyImage")) { var caseStudyImagesList =Model.Content.GetPropertyValue<string>("caseStudyImage").Split(newstring[]{","},StringSplitOptions.RemoveEmptyEntries).Select(int.Parse); var caseStudyImagesCollection =Umbraco.TypedMedia(caseStudyImagesList).Where(x => x !=null);
foreach(var caseStudyImage in caseStudyImagesCollection) { <img src="@caseStudyImage.Url"/> } }
The above renders the images just fine. But changing the img tag to:
Thanks for quick reply. I do not think :-) I am working with webforms - This case is inside: <umbraco:Macro runat="server" language="cshtml"> on template.
When using Umbraco v7 and WebForms all of your macros should be partial view macros, razor macros that use DynamicNode and are stored in "macroScripts" folder are only for legacy support.
Showing cropped images from multi media picker
Ok, so heres a noob question. Just getting into the 7 way of things coming from the xslt world of previous versions trying to get to grips with razor, so bear with me :)
Im trying to render a series of images cropped with the new cropper and chosen with the new multi media picker.
Using:
The above renders the images just fine. But changing the img tag to:
throws an error...
Any pointer as to what im doing wrong?
Hi Claus,
Are you using v7.1 beta or RC or a nightly?
Jeavon
7.1 RC
The code formatting f... my line. Heres what im trying:
<img src="@image.GetCropUrl("@caseStudyImage.Url", "Tester")" />
Ah wait, do you mean
<img src="@caseStudyImage.GetCropUrl("Tester")" />
where "Tester" is your Crop alias?Ok, caseStudyImage has the Cropper as the umbracoFile right?
Assuming that "Tester" is your Crop Alias, then
<img src="@caseStudyImage.GetCropUrl("Tester")" />
should work?Exactly, Thanks :)
Hi,
I hopy you will help me out. I am confused about this cropper. My code without crop:
Using your code gives error.
Thanks
Hi Anders,
Are you using a strongly typed partial view and passing a IPublishedContent model?
Jeavon
Hi
Thanks for quick reply. I do not think :-) I am working with webforms - This case is inside: <umbraco:Macro runat="server" language="cshtml"> on template.
Is this anwser ? :-)
Thanks
Ok, and is your macro a Partial View Macro? If not it needs to be.
When using Umbraco v7 and WebForms all of your macros should be partial view macros, razor macros that use DynamicNode and are stored in "macroScripts" folder are only for legacy support.
Hi, sorry I have to ask you further:
Now I have this code running partial view macro:
And now it displays image not the crop.
I have imageCropper datatype on media node:
What is the alias of the "cropper" on the document or image type?
Thanks.
Ah ok, you don't need to the crop property, you need to change "umbracoFile" from type "Upload" to type "ImageCropper".
I did a little Screenr here where you can see the process :-)
Arrrhh. Ofcourse. THANKS AGAIN
is working on a reply...