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

94
Views
Limitar las opciones de campo de entrada JS

Estoy trabajando en un sitio web de Wordpress y tengo un <input type="image"> muy simple a través del cual el usuario puede enviar archivos de imagen.

Tengo algunas solicitudes muy específicas y me gustaría que el archivo subido sea:

  • mínimo 3000x3000 píxeles
  • máximo 5000x5000 píxeles
  • máximo 36 MB
  • relación de aspecto 1:1

¿Hay alguna manera de establecer estos límites a través de JS/jQuery?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Para obtener información sobre la imagen antes de cargarla, use wp_handle_upload_prefilter . La relación de aspecto es comparar ancho y alto.

 function test($file) { $data = getimagesize($file['tmp_name']); error_log(print_r($data,true)); //Returns // Array ( // [0] => 3000 // width // [1] => 3000 // height // [2] => 3 // [3] => width="3000" height="30000" // [bits] => 8 // [mime] => image/png // ) error_log(print_r($file,true)); //returns // Array ( // [name] => filename.png // [type] => image/png // [tmp_name] => /tmp/phpEJC5NR // [error] => 0 // [size] => 4347 // file size in bits // ) return $file; } add_action('wp_handle_upload_prefilter','test');
about 4 years ago · Juan Pablo Isaza Report
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!