grok / wordpress-plugin-scalable-vector-graphics

Scalable Vector Graphics are two-dimensional vector graphics, that can be both static and dynamic. This plugin allows your to easily use them on your site.
http://sterlinghamilton.com/scalable-vector-graphics-plugin
GNU General Public License v2.0
15 stars 5 forks source link

Not working on WordPress 4.0 #5

Closed shield-9 closed 8 years ago

shield-9 commented 10 years ago

This plugin is not working on WordPress 4.0-beta4-20140824 with Grid View.

grok commented 10 years ago

I will test and get back to you.

grok commented 10 years ago

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.

grok commented 10 years ago

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.

grok commented 10 years ago

In IRC right now -- but the good new is, the non grid view still works :)

grok commented 10 years ago

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

pawdat commented 10 years ago

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);
Lewiscowles1986 commented 9 years ago

https://gist.github.com/Lewiscowles1986/44f059876ec205dd4d27 (a plugin that works)

&

https://core.trac.wordpress.org/ticket/31258#comment:10 (the resulting patch for core ;))

grok commented 9 years ago

Thanks Lewis!

Mind if I integrate that or a variation of it into this plugin?

Lewiscowles1986 commented 9 years ago

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.

grok commented 9 years ago

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...

grok commented 8 years ago

This is now pushed to github, will roll out to SVN when I get a moment.