-
Notifications
You must be signed in to change notification settings - Fork 2.8k
V9: Fix ImageSharp integration and add support for custom crops #10623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilder.ImageSharp.cs
Outdated
Show resolved
Hide resolved
I just found the ImageSharp.Web query string variable names were incorrect, for example |
src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilder.ImageSharp.cs
Outdated
Show resolved
Hide resolved
I've removed any Umbraco dependencies in Like @Jeavon already mentioned in #10715, we also need to look into |
I wouldn't recommend a like-for-like feature continuation. The idea should be that you have the most limited DDOS attack surface available. Some of those things ( |
src/Umbraco.Infrastructure/Media/ImageSharpImageUrlGenerator.cs
Outdated
Show resolved
Hide resolved
Besides the testing steps from the initial PR comment, also make sure to check whether changing the focal point uses the correct center position when resizing/cropping:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's where I've got to so far - have reviewed code, and looks good. I fixed up a couple of tiny things and pushed up some unit tests for the CropWebProcessor
and ImageCropperTemplateCoreExtensions
.
Will add an inline comment on some code that seems like it's not adding anything, and we could perhaps remove?
I'm unfortunately not understanding how to use a crop on the front-end... so I need some more instruction there! Probably something obvious that I'm missing,,, have shared on a Slack message.
src/Umbraco.Infrastructure/Media/ImageSharpImageUrlGenerator.cs
Outdated
Show resolved
Hide resolved
src/Umbraco.Infrastructure/Media/ImageSharpImageUrlGenerator.cs
Outdated
Show resolved
Hide resolved
src/Umbraco.Web.Common/Extensions/ImageCropperTemplateCoreExtensions.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I've verified now the changes in this PR, so approving.
…comments/documentation
…opImageUrlGenerator
After moving some things around, the latest commits ensure we're always using the same ImageSharp configuration (currently in the Note to all implementers: whenever you're using an ImageSharp API that allows injecting a |
This fixes an issue where custom crops was not reflected if you zoomed in or moved the crop around.
This was because we had replace
ImageProcessor
withImageSharp.Web
, which uses different parameters and doesn't support the type of cropping we use out of box.To fix this I created a custom Crop
IImageWebProcessor
which grabs the old crop parameter from the URL string, and recalculate it into the ImageSharpRectangle
format, and then crop the image, which will be sent on the resizer where it will be resized.I also considered creating a custom resizer that uses the TargetRectagle and the manual mode, however, I think this will be much harder to manage and maintain, than separating the concerns of cropping and resizing. The documentation is not entirely clear if it is at all possible to do it in this manner regardless.
Testing
To this out, you must
(You might have to clear your browser cache)
I made an image with a custom crop, before the changes it looked like:
After the changes: