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

174
Views
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
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!