I am trying to recreate a v7 site on v8.
Rendering (cropped) images are causing me some trouble though.
In the v7 template this works well
@if (Model.Content.HasValue("pageImage")) {
var foto = Model.Content.GetPropertyValue<IPublishedContent>("pageImage").GetCropUrl("100,100");
<p>@foto</p>}
Rewriting it for v8 like this does not
@if (Model.HasValue("pageImage")) {
var foto = Model.Value<IPublishedContent>("pageImage").GetCropUrl("100,100");
<p>@foto</p>}
If I just replace the stuff within {} with <p>Image goes here</p> the text renders nicely, so it must be the Model.Value string that needs adjusting. I can't figure it out. Any ideas?
Thank for the reply. But code is not working.
It is givinge the below error:
Value cannot be null.
Parameter name: mediaItem
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: mediaItem
In my case, Culture is allowed on the document type but not on the field. Please see below :
Also, should we continue to include the alias of cropping as below :
I might be necroing an old thread, but the official documentation and even the answers given above appear to not work as of the current version (8.6.3).
Calling Model.Value<IPublishedContent>("pageImage") just gives back null because it's not an IPublishedContent, it's an ImageCropperValue.
Here is the partial view that I created that appears to work properly.
How to render image crop URL in v8?
I am trying to recreate a v7 site on v8. Rendering (cropped) images are causing me some trouble though.
In the v7 template this works well
Rewriting it for v8 like this does not
If I just replace the stuff within
{}
with<p>Image goes here</p>
the text renders nicely, so it must be theModel.Value
string that needs adjusting. I can't figure it out. Any ideas?Hi Jesper
Try
The overloads for width and height are expecting integer values
regards
Marc
Hello Jesper,
I am using umbraco version 8.2.2.
When activating the culture on my document type, image cropper no more works.
is it the case for you as well ?
Thanks,
Kusum
Hi Kusum
I haven't really tested a live U8 site yet, so I do not really know, sorry.
Hope you find a solution.
Best
If you have activated the culture on your document type then you need to pass it like this
Hello Bo,
Thank for the reply. But code is not working. It is givinge the below error:
In my case, Culture is allowed on the document type but not on the field. Please see below :
Also, should we continue to include the alias of cropping as below :
If its not allowed in the property then this should work
I always do it this way
I might be necroing an old thread, but the official documentation and even the answers given above appear to not work as of the current version (8.6.3).
Calling
Model.Value<IPublishedContent>("pageImage")
just gives backnull
because it's not anIPublishedContent
, it's anImageCropperValue
.Here is the partial view that I created that appears to work properly.
Check out the class definition for ImageCropperValue for some other neat features it has.
is working on a reply...