Closed shield-9 closed 8 years ago
I will test and get back to you.
I've confirmed that it does upload the file, but does not display the image in the grid view.
This is present in the latest stable release of 4.0 -- working on a fix.
Here's what is causing it: https://github.com/WordPress/WordPress/blob/master/wp-includes/media-template.php#L440
Something to do with part of the meta data surrounding the file type. I'll need to take some time and hack on this. Could take me a while unless there's documentation.
I'll try and speak with core developers.
In IRC right now -- but the good new is, the non grid view still works :)
Spoke with fris in IRC and he pointed me to the plugin author.
I submitted a ticket: https://github.com/helenhousandi/wp-media-grid-view/issues/17
You can use wp_prepare_attachment_for_js
filter to append svg image url. I've used code below in one of projects i'm working on right now. Works fine with latest Wordpress 4.0.
function plugin_prepare_attachment_for_js_filter($response, $attachment, $meta){
if($response['mime'] == 'image/svg+xml' && empty($response['sizes'])){
$svg_file_path = get_attached_file($attachment->ID);
$orig_size = plugin_get_original_svg_size($svg_file_path); // use simplexml for example to get values of width and height or viewBox attributes
$response['sizes'] = array(
'full' => array(
'url' => $response['url'],
'width' => $orig_size[0],
'height' => $orig_size[1],
'orientation' => $orig_size[0] > $orig_size[1]?'landscape':'portrait'
)
);
}
return $response;
}
add_filter('wp_prepare_attachment_for_js', 'plugin_prepare_attachment_for_js_filter', 10, 3);
https://gist.github.com/Lewiscowles1986/44f059876ec205dd4d27 (a plugin that works)
&
https://core.trac.wordpress.org/ticket/31258#comment:10 (the resulting patch for core ;))
Thanks Lewis!
Mind if I integrate that or a variation of it into this plugin?
No problems grok, as you can see, I'm not willing to abandon Git to publish plugins hahaha. WordPress will have to catch up and even then, it's GNU licensed use, modify distribute etc. Thanks for asking, would also be nice to get a mention or something, but not required.
Of course man! Happy to include your github name and/or wordpress.org name in the commit/readme.
Of course...I need to actually find time to do all the things...
This is now pushed to github, will roll out to SVN when I get a moment.
This plugin is not working on WordPress 4.0-beta4-20140824 with Grid View.