CRUD: [3.6][Bug] Image field type doesn't allow SVG files
When adding a field like this:
$this->crud->addField([
'label' => "Icon",
'name' => "icon-image",
'type' => "image",
'fake' => true,
]);
… the JavaScript in src/resources/views/fields/image.blade.php will run a test against the file that will fail when it shouldn’t, and the JS will then do alert("Please choose an image file.");. (Several times, in fact, but that’s a different issue.) SVGs should just work, like the other image types do.
The test should be modified to allow SVG images to work.
See my original comment here for my suggested solution.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (8 by maintainers)
@packytagliaferro I proposed a hack in a comment here that allowed me to copy
vendor/backpack/crud/src/resources/views/fields/image.blade.phptoresources/views/vendor/backpack/crud/fields/image.blade.phpand changeif (/^image\/\w+$/.test(file.type))toif (/^image\/[\w\+]+$/.test(file.type)). I don’t know that that’s the best solution, but it works for me quite well, so if you’re looking for a “hack”, there you go.https://laravel.com/docs/5.4/validation#rule-image - we could just lean on the Laravel validators…