Testing umbraco v8 i would like to show an image on my multilingual website.
I have danish and english language.
It should be possible to have different images on each language, but if no image is set on danish, it should fallback to the english image. In this case it is a image cropper data type, but could be a image picker as well.
The GetCropUrl() is an extensionmethod on IPublishedContent, so you first can get the fallback IPublishedContent and then use the GetCropUrl() on that IPublishedContent
I couldn't get this working either - have created a PR to add some overloads to the GetCropUrl method that should allow using language and fallbacks. Not sure if a better way already exists, but will perhaps see when the PR is reviewed.
Thanks the effort. Really appreciated. This was driving me nuts, so glad to see that there actually seems to be an issue.
I will let this thread be unsolved until we know further about Andy's PR :)
Fallback on crop url in V8
Hi umbracians,
Testing umbraco v8 i would like to show an image on my multilingual website. I have danish and english language. It should be possible to have different images on each language, but if no image is set on danish, it should fallback to the english image. In this case it is a image cropper data type, but could be a image picker as well.
It works fine if i do this:
But what if I want to have the cropped image?
How can i implement fallback here? Is it possible?
Hi Hundebol,
Try this:
The
GetCropUrl()
is an extensionmethod onIPublishedContent
, so you first can get the fallbackIPublishedContent
and then use theGetCropUrl()
on thatIPublishedContent
Hi Corné,
Thanks, but that does not seem to work. I get the following: CS1503: Argument 1: cannot convert from 'method group' to 'HelperResult' :(
Other ideas?
I'm not on my PC, but try removing the
)
at the end of my code example. I think that throws the exceptionI did see the little typo, and had removed that. But no luck. Still the same error. There must be a way :(
I couldn't get this working either - have created a PR to add some overloads to the
GetCropUrl
method that should allow using language and fallbacks. Not sure if a better way already exists, but will perhaps see when the PR is reviewed.Andy
Interesting, I have no errors and it works as expected.
I'm trying to understand the error you're getting. Can it be you must surround your code with
(
and)
, like this:I think this issue is that the field is of type "Image Cropper" (rather than "Media Picker") - and hence you don't get an
IPublishedContent
back?I think you're right, but I don't get any errors when I change my property from Media picker type to Image Cropper type.
When using Image Cropper directly on content type there is indeed a issue with getting the fallback value, so good job @Andy you made a PR for this.
(Temporary?) solution maybe for @Hundebol is moving to Media picker instead of the Image Cropper directly. That is how my example was configured.
Hi Andy and Corné,
Thanks the effort. Really appreciated. This was driving me nuts, so glad to see that there actually seems to be an issue. I will let this thread be unsolved until we know further about Andy's PR :)
Thanks for the help so far you guys :)
Hi,
I worked around this by checking the model value first to see if it was null and rendering a constant if it was:
Hello,
I am using the same code as above but I am getting an empty image.
Can someone please help.
Thanks,
Kusum
is working on a reply...