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

172
Vistas
WP.Media: Is it possible to set a limit to how many photos/images can be uploaded via WP.Media?

I am creating a 3D model editor, in which there is a texture called CubeTexture, it needs 6 photos to get it working. So I am looking for a way to limit WP.Media to a minimum and maximum of 6 files. I am not looking for a way to limit the upload size, but the number of files specifically.

I think the documentation for all parameters is lacking since I could not find any summary for all possible parameters (only a handful of questions in StackOverflow using different parameters in each).

What I have so far to solve this problem is:

let frame = wp.media({
    title: "Selecione ou carregue uma mídia",
    button: { text: "Usar esta mídia" },
    multiple: true // set to "true"
});

frame.on("select", () => {
    let attachments = frame.state().get("selection").toJSON();
    attachments = attachments.slice(0, 6); // get the first 6
    
    this.update(canvas, attachments);
    callback(attachments);
});
                
frame.open();

But, that would let the user to choose less than six, so we could add:

if (attachments.length < 7) {
     // restart wp.media somehow
}

But I don't know how to restart the wp.media nor if I could solve this by adding some parameter(s), or if I could even solve this with PHP.

Thanks in advance!

about 4 years ago · Juan Pablo Isaza
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