Before if an image was not set in the CMS we could fallback to a local Image in the source code and then also crop it I can no longer get this to work in Umbraco 11.
I have also tried this.
var imageUrl = Model.Value<IPublishedContent>("image",fallback: Fallback.ToDefaultValue, defaultValue: "/images/logos/fallback-logo.png");
Yes, it looks like some of the usual UrlHelpers got waylaid in the move to .net core.
using Url.GetCropUrl was always the suggested new 'best way' to replace using GetCropUrl extension methods that existed on IPublishedContent or the string...
... ironically it looks like the older approach has been moved across to .net core, under the guise of the FriendlyImageCropperTemplateExtensions:
But agree it would be good to get the Extension methods added to UrlHelper, so you could write the same Url.GetCropUrl and pass in a string, maybe there was a reason to remove them, this commit
GetCropUrl No longer works with local images
In Umbraco 8 GetCropUrl could be used with a string of the images path not just the publishedcontentmodel
Before if an image was not set in the CMS we could fallback to a local Image in the source code and then also crop it I can no longer get this to work in Umbraco 11. I have also tried this.
Hi Perry
Yes, it looks like some of the usual UrlHelpers got waylaid in the move to .net core.
using Url.GetCropUrl was always the suggested new 'best way' to replace using GetCropUrl extension methods that existed on IPublishedContent or the string...
... ironically it looks like the older approach has been moved across to .net core, under the guise of the FriendlyImageCropperTemplateExtensions:
https://github.com/umbraco/Umbraco-CMS/blob/5ef43cb4f043e4d6910c213972bc68ba7c068ceb/src/Umbraco.Web.Common/Extensions/FriendlyImageCropperTemplateExtensions.cs
So if you have an @using Umbraco.Extensions in your template you should be able to write
But agree it would be good to get the Extension methods added to UrlHelper, so you could write the same Url.GetCropUrl and pass in a string, maybe there was a reason to remove them, this commit
https://github.com/umbraco/Umbraco-CMS/commit/6d97cbd95471acb1081bc710aa3e3fa77301537b
seems to show they might have just been missed.
regards
Marc
Ah woops i should have noticed that.
i guess i've got a lot of refactoring to do I think i will open a Github ticket too to see if it can come back.
is working on a reply...