How we can trigger events manually. for example, I want to remove image if greater then specific size.
var imageInputElement = document.querySelector("#kt_image_input_control");
var imageInput = new KTImageInput(imageInputElement);
imageInput.on("kt.imageinput.changed", function(e) {
var files = e.inputElement.files;
var file = files[0];
var size = file.size / 1024 / 1024;
if(size > profile_pic_size_limit) {
toastr.error('El tamaño del archivo no puede ser más de 1mb');
console.log(imageInput)
imageInput.trigger('kt.imageinput.cancel','click');
imageInput.trigger('click','kt.imageinput.cancel');
return;
}
}
Hi,
You can trigger it using DOM event trigerring:
imageInput.getElement().query("[data-kt-image-input-action="cancel"]").click();