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
Better crop mechanism for the grid image editor #8023
Better crop mechanism for the grid image editor #8023
Conversation
Has old controls for testing, will be removed.
Localization key for crop setting.
Hey Lars! Wonderful to see you here 😊 We'll take a look at the work and if we have questions, we'll ask. Speak soon, Em |
Cheers, @emmaburstow! :) I've been wondering whether it should be introduced as a new editor type, compatible with the old one. Otherwise it'll be breaking since Media.cshtml have to be changed and often is not on upgrade. L-E |
It works again with #8048 merged. |
…-media-crop # Conflicts: # src/Umbraco.Web.UI.Client/src/utilities.js
I've managed to have the picker open the details dialog when you already have a selected image with a crop. The RTE picker should not be affected (ie. work as before w/preview). A bug with both in the current Umbraco version is that they won't change folder to the image's folder. I might visit that before finishing up. Still trying to have the cropper center initially, and likewise use the existing focal point when editing an "unset crop" in the media section. Seems like someone forgot about the existing focal point when making the cropping directive. Need to do some slightly complex math to get it done, but think I'll be able. Also still unsure about modifying the existing media view, but also still open for suggestions. Not to mention the fact that I'm starved for attention here. |
There! Image cropper property editor now initially centers crops on focal point. RTE and Grid media pickers change folder to the parent of items when you pop the dialog for existing selected/cropped media. Here's a new demo showing the changes from the previous one: Then we're left with what to do with the razor view for the grid media editor. Thoughts? PS. Couldn't help myself but to standardize some whitespace. Luckily GH now has "ignore WS changes". 😇 |
Sorry @lars-erik I've not read all of the comments yet, but I want to put your mind at ease about something:
People need to update this file during an upgrade, this is not something that would be considered a breaking change. |
Cheers @nul800sebastiaan. Then I'll let it rest for now. |
👍 There's a "few" more that need merging.. 🙈 Or .. do you mean any of Bjarne's changes are related to this? |
I've moved my code to the files he PR'd in #8048 |
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.
What a wonderful improvement :) Thanks for the work Lars. You're a ⭐
@nul800sebastiaan @bjarnef alerted me he'd moved the code I was changing in his #8048. So I merged that and now this PR requires #8048. I can move it back, but his changes seem legit to me. |
Although I'm fairly certain merging this PR would automerge #8048 as well. 😊 |
I do apologize for the delay @lars-erik - it took me way longer than I wanted to to evaluate this one. This is super cool!! Next time I would love for you to post some steps to test in text, this bit in {
"name": "Image",
"nameTemplate": "{{ value && value.udi ? (value.udi | ncNodeName) : '' }}",
"alias": "media",
"view": "media",
"config": {
"size": {
"width": 500,
"height": 500
}
},
"icon": "icon-picture"
},
{
"name": "Portrait Image",
"nameTemplate": "{{ value && value.udi ? (value.udi | ncNodeName) : '' }}",
"alias": "media.portrait",
"view": "media",
"config": {
"size": {
"width": 450,
"height": 800
}
},
"icon": "icon-picture"
},
{
"name": "Landscape Image",
"nameTemplate": "{{ value && value.udi ? (value.udi | ncNodeName) : '' }}",
"alias": "media.landscape",
"view": "media",
"config": {
"size": {
"width": 800,
"height": 450
}
},
"icon": "icon-picture"
}, Other than that code looks great, everything works and nothing blows up if people forget to update Media.cshtml so I'm very happy with this one! 👍 Thanks a million!! |
Just had a read-through of this and this seems like a downgrade to me. Focal-point cropping makes it possible to have different crops of an image based on for example screen size. I have a custom Media.cshtml that can do this, by rendering a different size on smaller phones. With the removal of the focal point crop, this is no longer possible. Having the option to do both is fine (like in the Image Cropper property editor), but removing focal point is not a good idea, in my opinion. |
@arknu My grief about this is that you get no feedback in the editor, and the preview was broken when you had set a crop. Thoughts? |
Just to make it clear: this ONLY gives you a cropper if you setup specific config for it manually. Otherwise you keep seeing the focal point (and as a bonus, editing the focal point now for the first time actually works). If we broke something with the focal point, however then please let me know @arknu so we can have a look. |
@nul800sebastiaan That sounds alright then :) I can just rename the config to something else. I still think that being able to specify a width and height and a focal point should be possible, but that easily be solved with a custom grid editor. |
Prerequisites
Description
Relies on #8014. Obsoletes #8013.
Replaces the old "focal point" crop mechanism in the grid with the same mechanism that is on the imagecropper datatype. Keeps code to support the focal point mechanism in views and front-end in order not to break existing solutions.
Also fixes black padding on images with config.size but no focalPoint selected. (Ex. default 0.5,0.5 shown is not respected)
Before - OOTB on v8/contrib with default starter kit:
https://youtu.be/wYqqGnKIVtI
After - OOTB on v8/contrib with default starter kit:
https://youtu.be/4orR6iI-Wao
For another time, I'll try to bring back aspect ratio, but would have to change from entityResource to mediaResource, which lost its search, so won't work without more changes. When we have aspect ratio, we can make the crop GUI center on the image instead of cropping from 0,0.