Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

125
Vistas
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 Respuestas
Responde la pregunta

0

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

about 4 years ago · Juan Pablo Isaza Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda