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!