Last active
December 24, 2015 22:30
-
-
Save fntneves/3f0c260de1aa9399236e to your computer and use it in GitHub Desktop.
Validator extension for Image Data URI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Validator::extend('image_uri', function($attribute, $value, $parameters, $validator) { | |
$matches = []; | |
$pattern = '/^data:image\/(jpe?g|png|bmp|gif|svg);base64\,.+$/'; | |
return preg_match($pattern, $value, $matches) > 0 && in_array($matches[1], $parameters); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: