Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda