[application.media]
BSBjorn opened this issue · comments
Hi.
I'm trying to enble support for SVG uploads, but it is not registered. The CPT is configured and working, so I'm sure the plugins is actuve. Am I doing it wrong?
return [ 'application' => [ 'posts' => [ 'cabin' => [ 'one' => 'Hytte', 'many' => 'Hytter', 'supports' => [ 'title', 'thumbnail', 'editor', 'excerpt', 'author' , 'event_cat' ], 'show-in-rest' => true, 'has-archive' => true, 'hierarchical' => false, 'menu_icon' => 'data:image/svg+xml;base64,' . base64_encode($cabinIcon), 'menu-position' => 10, ], ], 'taxonomies' => [ 'cabinManufacturers' => [ 'one' => 'Hytte leverandør', 'many' => 'Hytte leverandører', 'links' => [ 'cabin' ], 'hierarchical' => true, 'show-in-rest' => true ] ], 'media' => [ 'mimes.svg' => true, ], ],
Hey @BSBjorn,
Just tested your config locally and can confirm it's working as expected on my side. Are you not able to upload svgs with the above config?
Thats is correct. I still get the error "Asset 1.svg Sorry, you are not allowed to upload this file type".
Wordpress 5.9, Bedrock, Sage 10 beta 2 is my settup
@BSBjorn if you add this to functions.php
does it work?
add_action('upload_mimes', function($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
});
Intervention essentially uses this so just trying to debug what it could be.
That does not work either... This is a neraly fresh install of sage10 and bedrock...
That is odd, any other plugins installed? Security ones, etc? If you search the whole codebase, any other reference to upload_mimes
?
Only reference to upload_mimes is in /web/app/mu-plugins/intervention/src/Application/Media/Mimes.php
And core wp-include files
@BSBjorn Hmm, very odd, let me give it a think or try to recreate with Bedrock.
@darrenjacoby thanks! Let me know if you need anything more from me. :)
FYI, I just testet on another site I have running. Same result.
@BSBjorn also a bedrock based site? Could you test on a non-Bedrock site? Just want to rule it out.
Yeah, same setup, Bedrock and Sage 10. Don't have any non bedrock projects with sage... I'll see if I can do some magic
@BSBjorn can you try add this to your functions.php
file and test.
add_filter('wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) {
$wp_filetype = wp_check_filetype($filename, $mimes);
return [
'ext' => $wp_filetype['ext'],
'type' => $wp_filetype['type'],
'proper_filename' => $data['proper_filename']
];
}, 10, 4);
That worked! I put it in the app/filters.php file and instantly working.
Great, thank you for helping debug. It seems related to the WP version and a change that was made sometime with 4.7.1+. At the time there was mention it would be resolved in the next release, but it seems to persist. So I will include this fix in Intervention for the next version.
Happy to help! Thanks for a superb plugin, just makes working with WP alot better. 👍
Tested and working like a dream now! :D
Glad to hear! Thanks for testing so fast and appreciate the issue as well! I'll close this for now.