So my company wants me to make a small blog on the main website and everything goes well, only...
I was hitting my head against the wall today as I was used to umbraco 7. Now, apparently Umbraco 6 doesn't have the very handy @Url.GetCropUrl
Which brings me to my next problem. Tried to find the documentation for that version and nothing on the web. Anyone has any clues on where I can find the previous documentation about the Image Cropper in v6.1 and how to grab the cropped urls with Razor?
Unfortunately it didn't help. I did what the documentation told me using Razor and unfortunately MediaById returns error:
RenderModel does not contain a definition of "MediaById' and no extension method 'MediaById' accepting a first argument of Type "RenderModel" could be found (are you missing an assembly reference?)
here's where it gets really weird. When I saw the documentation won't help me (as per usual) I tried stuff on my own. I have a Blog Document Type and then a descendant(3rd level I think) which is named BlogPost.
I'm using this code in BlogPost:
@if (Model.Content.HasValue("blogBanner"))
{
var bannerImage = Umbraco.Media(Model.Content.GetPropertyValue<string>("blogBanner"));
var croppedPhoto = bannerImage.thumbnails.crops.Find("@name", "BlogBanner").url;
<img src="@croppedPhoto" alt="@croppedPhoto" />
}
To get the crop ("BlogBanner") from the Image Cropper "thumbnails" and it works. I go back to the Blog, grand-grandparent and I use this code:
'Umbraco.Core.Dynamics.DynamicXml' does not contain a definition for 'url'
On the @croppedPhoto variable. I have NO IDEA how to make it work. I've tried everything. It's a media picker by the way if that helps. I tried Upload image instead of Media Picker, but it's the same exact result.
Umbraco v6.1.6 and Cropped Url Problem
So my company wants me to make a small blog on the main website and everything goes well, only...
I was hitting my head against the wall today as I was used to umbraco 7. Now, apparently Umbraco 6 doesn't have the very handy
@Url.GetCropUrl
Which brings me to my next problem. Tried to find the documentation for that version and nothing on the web. Anyone has any clues on where I can find the previous documentation about the Image Cropper in v6.1 and how to grab the cropped urls with Razor?Thank you in advance.
Hi Harry,
Perhaps this old documentation can help you in the right direction try to look at https://github.com/umbraco/UmbracoDocs/blob/v7-documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors/Image-Cropper.md
If you not are using Dynamic Razor in your 6.1.6 then you need to make some changes to the Razor code that you are seen in the example.
Hope this can help you in the right direction.
/Dennis
Hello Dennis,
Unfortunately it didn't help. I did what the documentation told me using Razor and unfortunately MediaById returns error:
RenderModel does not contain a definition of "MediaById' and no extension method 'MediaById' accepting a first argument of Type "RenderModel" could be found (are you missing an assembly reference?)
my @using are:
here's where it gets really weird. When I saw the documentation won't help me (as per usual) I tried stuff on my own. I have a Blog Document Type and then a descendant(3rd level I think) which is named BlogPost.
I'm using this code in BlogPost:
To get the crop ("BlogBanner") from the Image Cropper "thumbnails" and it works. I go back to the Blog, grand-grandparent and I use this code:
and it DOESN'T WORK...... Throws an exception:
'Umbraco.Core.Dynamics.DynamicXml' does not contain a definition for 'url'
On the @croppedPhoto variable. I have NO IDEA how to make it work. I've tried everything. It's a media picker by the way if that helps. I tried Upload image instead of Media Picker, but it's the same exact result.
Hi Harry,
Perhaps you could consider using this package https://our.umbraco.org/projects/website-utilities/eksponent-cropup
Try to see JeavonĀ“s comment in this thread:
https://our.umbraco.org/forum/developers/razor/53413-Getting-Image-Crop-from-media-picker-file
Hope this helps,
/Dennis
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.