-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
How to set new image editor with custom crop ratio and use can't change it #248
Comments
In conclusion, you can use the
Thank you for your inquiry. Internally, we will consider supporting more detailed options over time. |
@jinwoo-kim-nhn It would be very helpful for me if you can share something with example, which is fixing this issue. |
This issue has been automatically marked as inactive because there hasn’t been much going on it lately. It is going to be closed after 7 days. Thanks! |
Is this issue achievable because I want something like it to prevent user from drawing a rectangle with random aspect ratio while he is cropping the image but just he can use the initial one. |
This issue has been automatically marked as inactive because there hasn’t been much going on it lately. It is going to be closed after 7 days. Thanks! |
This issue will be closed due to inactivity. Thanks for your contribution! |
Any updates on this issue? |
Hi, Remark : the solution is ugly because there is no callback prop on the component to know when the selected menu changes. It would be nice to add a I use the ImageEditor with React Here's how I solved the problem : export default function ImageFileUpload({ value, onChange, acceptedRatio }) {
const [currentActiveMenu, setCurrentActiveMenu] = React.useState(null);
useInterval(
() => {
if (!acceptedRatio) return; // I don't have a ratio to force
// Building a listener to active menu changes
// I use JQuery to check which menu is active
const [el] = $('.tui-image-editor-menu .tui-image-editor-item.active');
if (!el) return;
const newActiveMenu = el.className.split('tie-btn-')[1].split(' ')[0];
if (newActiveMenu === currentActiveMenu) return;
setCurrentActiveMenu(newActiveMenu);
if (newActiveMenu !== 'crop') return;
// If it is the crop menu, I try to set the cropzone to my own ratio
// My ratio shape is like '16:9'
const [width, height] = acceptedRatio.split(':');
try {
editorInstance.setCropzoneRect(
parseInt(width, 10) / parseInt(height, 10)
);
} catch (e) {
console.error(e);
}
},
// Delay in milliseconds
300
);
return (
<div
className={classNames('image-file-upload', {
'has-preset-ratio': !!acceptedRatio,
})}
>
<ImageEditor ... />
</div>
)
} And the CSS part : .image-file-upload {
&.has-preset-ratio {
.tui-image-editor-container .tui-image-editor-submenu {
height: unset;
padding-bottom: 10px;
.tui-image-editor-menu-crop
.tui-image-editor-submenu-item
li:not(.tie-crop-button.action) {
display: none;
}
}
}
} |
Hey @junghwan-park ,
Thanks for really nice and helpful library.
@junghwan-park i want to achieve something like this.
When image editor is open i want to initialize direct crop menu. I can achieve this using
initMenu: 'crop'
. Once this crop is menu will be show,16:9
,7:5
,3:2
,custom
). How can i achieve this?(or aspect ratio like 5:1 or 2:1 or any others. This aspect ratio will automatically set on image and user can't change it. But user can drag it and set to different part of image. So, once user will click on apply button selected crop area will be automatically croped)
by default in editor which i will pass into imageEditor configuration object or after configured some functions likeimageEditor.crop(....)
.In, short i want to initialize image editor with my custom crop ratio and which will by default set on image, this crop ratio user can't change.
Thanks
The text was updated successfully, but these errors were encountered: