Advertisement
LautaroSanchez

as

May 1st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <?php
  2.  
  3. namespace JBBCode\validators;
  4.  
  5. require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'InputValidator.php';
  6.  
  7. /**
  8. * Un InputValidator para url de imagen válida
  9. *
  10. * @author PHPost
  11. * @since Nov 2015
  12. */
  13. class ImgValidator implements \JBBCode\InputValidator {
  14.  
  15. /**
  16. * Retorna true si $input es un enlace que muestra una imagen con los formatos más utilizados
  17. *
  18. * @param $input texto para validar
  19. */
  20. public function validate($input) {
  21. $img['url'] = $input;
  22. $img['size'] = getimagesize($img['url']);
  23. $img['type'] = $img['size'][2];
  24.  
  25. return (bool)(in_array($img['type'], array(IMAGETYPE_GIF , IMAGETYPE_JPEG ,IMAGETYPE_PNG , IMAGETYPE_BMP)));
  26. }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement