wpalchemy icon indicating copy to clipboard operation
wpalchemy copied to clipboard

MediaAccess and WordPress 3.5

Open sirjonathan opened this issue 12 years ago • 15 comments

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

sirjonathan avatar Dec 13 '12 01:12 sirjonathan

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

midnightdonkey avatar Dec 14 '12 17:12 midnightdonkey

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

midnightdonkey avatar Dec 14 '12 18:12 midnightdonkey

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

sirjonathan avatar Jan 20 '13 15:01 sirjonathan

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

Flabadab avatar Apr 18 '13 13:04 Flabadab

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.

aolin480 avatar Aug 21 '13 15:08 aolin480

@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

Flabadab avatar Aug 22 '13 08:08 Flabadab

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?

aolin480 avatar Aug 27 '13 18:08 aolin480

@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

Flabadab avatar Aug 28 '13 20:08 Flabadab

@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?

kmh3785 avatar Oct 23 '13 22:10 kmh3785

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

Flabadab avatar Oct 26 '13 13:10 Flabadab

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

kmh3785 avatar Oct 28 '13 14:10 kmh3785

@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?

AlchemyCompSol avatar Dec 06 '13 17:12 AlchemyCompSol

@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

Flabadab avatar Dec 07 '13 14:12 Flabadab

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!

AlchemyCompSol avatar Dec 10 '13 01:12 AlchemyCompSol

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

BenHarris avatar Mar 10 '14 18:03 BenHarris