Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
Summernote rich text editor-restrict image above particular height and width

When I upload image in editor, I am able to find it's size. But I want it's height and width to restrict for height and width above particular limit. Below is result which I'm getting when I upload image.

See image to image upload result

For size restriction it's working as below-

onImageUpload(images, insertImage) {
    if (images[0].size <= 100000) {
        for (let i = 0; i < images.length; i++) {
            const reader = new FileReader();
            reader.onloadend = () => {
                insertImage(reader.result);
            };
            reader.readAsDataURL(images[i]);
        }
    } else {
        alert('Image not saved, max allowed image size is 100kb');
    }

};

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

What editor are you using? UEditor is a very good rich-text editor.

about 4 years ago · Juan Pablo Isaza Report

0

onImageUpload(images, insertImage) {
    console.log('onImageUpload', images);
    if (images[0].size <= 100000) {
        for (let i = 0; i < images.length; i++) {
            const reader = new FileReader();
            reader.onloadend = () => {
                var i = new Image();
                i.src = reader.result;
                i.onload = function () {
                    if (i.width <= 200 && i.height <= 200) {
                        insertImage(reader.result);
                    } else {
                        cogoToast.warn('Image not saved, image width and height should be less than 200*200');
                    }
                };
            };
            reader.readAsDataURL(images[i]);
        }
    } else {
        cogoToast.warn('Image not saved, max allowed image size is 100kb');
    }
};

It will work in this way.Thanks!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!