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

MediaAccess and WordPress 3.5 #59

Open
sirjonathan opened this issue Dec 13, 2012 · 15 comments
Open

MediaAccess and WordPress 3.5 #59

sirjonathan opened this issue Dec 13, 2012 · 15 comments

Comments

@sirjonathan
Copy link

I'd love to see the MediaAccess class updated to work with the new WordPress 3.5 media manager.

@midnightdonkey
Copy link

Me too, doesn't seem to be working anymore..

@midnightdonkey
Copy link

Ah - the media uploader is only broken if the post type doesn't have the editor. Once the main editor is included on the page, the uploader works just fine..

@sirjonathan
Copy link
Author

To be clear, I'd like it to use the new media manager, rather than the old.

@Flabadab
Copy link

I know this is a few month's old, but I've successfully modified MediaAccess.php to use the /new/ media manager if you guys are still interested.

I've only tested it with a simple upload field, but that's all i need it for. Perhaps someone can test and let me know if it works in more complex situations.

https://github.com/Flabadab/wpalchemy/blob/master/wp-content/wpalchemy/MediaAccess.php

@aolin480
Copy link

I tried your solution Flabadab and it works great, but the only problem is that the new media upload pops up. I select a media file, hit the button, the new media modal closes, but the old media upload box is showing behind that (basically, when I hit the button to add a media file, it's opening the new media uploader in front of the old media loader).

I have fixed this in a dirty way by using the following:

$('.media-modal-icon').click(function(){
    $('#TB_overlay').fadeOut();
    $('#TB_window').fadeOut();      
});

But it would be great if it didn't pop up at all. The only thing is, when the old media box it up, there is no content in it, it's just the old media box, and that's it. No content in the #TB_window div.

@Flabadab
Copy link

@aolin480 : I suspect it might be because of line 222 in my code - I accidentally left the "thickbox" css class in the button link, so if you are loading the old thickbox scripts, they will more than likely try to execute when the button is clicked.

I have revised the script:

https://github.com/Flabadab/wpalchemy/blob/master/wp-content/wpalchemy/MediaAccess.php

@aolin480
Copy link

Thats weird... I copy and pasted the new MediaAccess.php code in my MediaAccess.php and when I click on the Add PDF button I created it just goes to the media admin page. No lightbox or modal comes up. I reloaded the old script, and just took thickbox out of return $this->button_class_name . '-' . $groupname . ' thickbox'; and that works fine. Would I need to update my MetaBox.php with new code too?

@Flabadab
Copy link

@aolin480 sorry about that. I've just tested on a clean WP install and I see what you mean.

I fixed it by including

wp_enqueue_script('jquery') 

on line 92, when it checks for the 'wp_enqueue_media' function.

https://github.com/Flabadab/wpalchemy/blob/master/wp-content/wpalchemy/MediaAccess.php

@kmh3785
Copy link

kmh3785 commented Oct 23, 2013

@Flabadab - the script above does fix the upload box for WP Alchemy, but it also breaks the built in 'Featured Image' upload in Wordpress. The box pops up, lets you select a file to upload, but it does not attach.

Any idea why?

@Flabadab
Copy link

@kmh3785 - I've been told that including jQuery the way I did it is not the right way to do it, so I've made a minor tweak to the script. I have tested this on a vanilla WP install with WP Alchemy and the twentythirteen theme and I am able to set a featured image.

@kmh3785
Copy link

kmh3785 commented Oct 28, 2013

@Flabadab - Perfect, looks like it's working correctly now! Thanks.

@AlchemyCompSol
Copy link

@Flabadab I'm having really weird issues using your MediaAccess. I have used it on a few projects with no problem, but on my latest project, it has mysteriously stopped working. I set up some meta boxes, added image upload fields with your MediaAcess, and everything was working perfectly. Then I created a new post, and it didn't work on the new post. On the new post, when I click the "add media" button, it goes to a new page with the old pre-3.5 media uploader. What makes this extra bizarre is that the new modal post-3.5 media uploader still works on previously-created posts. There are no errors in the console or in the error log or anywhere else. Do you have any idea what might be happening here?

@Flabadab
Copy link

Flabadab commented Dec 7, 2013

@AlchemyCompSol The problem was that the media_scripts test in __contruct() function preventing the javascript libraries from loading on new posts. I've moved this check further down into the init() function and used $post_ID for the check instead of $_REQUEST('post') and this seems to have resolved the problem. Tested on WP 3.7.1 and WP 3.8 RC 1.

https://github.com/Flabadab/wpalchemy/blob/master/wp-content/wpalchemy/MediaAccess.php

@AlchemyCompSol
Copy link

Oops, I didn't see your response. Thank you for the fast response and the lovely fix! That definitely fixed the problem. I really appreciate it!

@BenHarris
Copy link

Works perfectly; thank you very much! Might be worth putting in a pull request?

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

No branches or pull requests

7 participants