Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG refused #27

Closed
tanthammar opened this issue Nov 24, 2018 · 7 comments
Closed

SVG refused #27

tanthammar opened this issue Nov 24, 2018 · 7 comments
Labels
enhancement New feature or request

Comments

@tanthammar
Copy link

I defined one of my Mediacollections to allow svg:s.
When I try to upload an svg I get the error; "must be an image".

$this->addMediaCollection('logo')
            ->singleFile()
            ->acceptsFile(function (File $file) {
                return in_array($file->mimeType, ['image/jpeg', 'image/png', 'image/gif', 'image/tiff', 'image/webp', 'image/svg+xml']);
            });
@ebess ebess added the enhancement New feature or request label Dec 10, 2018
@audetcameron
Copy link

Any update on SVG support in laravel nova?

@sigaev-pro
Copy link

SVG is a must-have feature for nowadays!

@idragon81
Copy link

I can confirm SVG works partially.
This library is using Laravel's image validation. Laravel seems to have an issue while validating SVGs with mime type image/svg, but it works fine for mime type image/svg+xml

I have raised an issue with laravel laravel/framework#26990

For the meantime I can only suggest you to change the mime type. Most SVG Cleaners and optimizers do this for you.

@ArmeniaH
Copy link

any other solutions for this, svg really is a must. Maybe we can override the core to have our own validation ?

@ebess
Copy link
Owner

ebess commented Apr 19, 2019

Checked it with laravel 5.8, working fine.

@ebess ebess closed this as completed Apr 19, 2019
@nemrutco
Copy link
Contributor

i am on laravel 5.8 faced the issue today. Can't upload svg usuing Image field. i get the error ".. must be an image." Can you confirm it's working?

@nemrutco
Copy link
Contributor

nemrutco commented Sep 11, 2019

Just figured out. Correct it works fine. But you have to make sure your svg contains

<?xml version="1.0" encoding="iso-8859-1"?> 

in first line. Some svg files does not has

<?xml version="1.0" encoding="iso-8859-1"?> 

(for example font-awesome svg files). So this cause validation error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants