Skip to content
This repository has been archived by the owner on Nov 30, 2020. It is now read-only.

Not working on WordPress 4.0 #5

Closed
shield-9 opened this issue Aug 25, 2014 · 11 comments
Closed

Not working on WordPress 4.0 #5

shield-9 opened this issue Aug 25, 2014 · 11 comments

Comments

@shield-9
Copy link
Contributor

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

@grok
Copy link
Owner

grok commented Sep 5, 2014

I will test and get back to you.

@grok
Copy link
Owner

grok commented Sep 5, 2014

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
Copy link
Owner

grok commented Sep 5, 2014

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
Copy link
Owner

grok commented Sep 5, 2014

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

@grok
Copy link
Owner

grok commented Sep 5, 2014

Spoke with fris in IRC and he pointed me to the plugin author.

I submitted a ticket: helen/wp-media-grid-view#17

@pawdat
Copy link

pawdat commented Oct 14, 2014

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
Copy link

@grok
Copy link
Owner

grok commented Apr 14, 2015

Thanks Lewis!

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

@Lewiscowles1986
Copy link

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
Copy link
Owner

grok commented Apr 15, 2015

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
Copy link
Owner

grok commented Jul 28, 2016

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

@grok grok closed this as completed Jul 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants