Unable to upload Media via Social tab on Custom Post Types #911

Drethic opened this Issue Mar 21, 2014 · 1 comment


None yet

2 participants

Drethic commented Mar 21, 2014

Currently I am using Version of wordpress-seo and if I go into my the admin section of my Plugin, which uses a Custom Post Type, and into the Social tab of Yoast the Upload button returns this error in the console:

Uncaught TypeError: Cannot read property 'frames' of undefined wp-seo-metabox.min.js?ver=

After a little bit of research I found this site: http://kingpro.me/article/author/ashdurham/ which mentions

Uncaught TypeError: Cannot read property 'frames' of undefined
If you are getting this error, include ‘wp_enqueue_media()‘ in your ‘admin_enqueue_scripts‘ action.

After looking around within my plugin I tried adding that within my constructor to overcome the issue and prevent having to modify a contributed plugin, however, that doesn't seem to pull it in the correct scope for your usage. I dug into your code and found where you are calling in your admin JS/CSS files and was able to add in the wp_enqueue_media() function. As soon as I did that the button began to work as expected and did not seem to break any other parts of the normal WordPress core functionality.

Where I updated wordpress-seo was in wordpress-seo/admin/class-admin within function config_page_scripts(). I added wp_enqueue_media() on line 495 just above your wp_enqueue_script to keep within the scope of your permissions.

Hopefully this is an easy fix that can be incorporated into your next patch so those of us using Yoast on Custom Post Types can leverage the Social Media uploads.

@jrfnl jrfnl added a commit to jrfnl/wordpress-seo that referenced this issue Mar 22, 2014
@jrfnl jrfnl Issue #911 - fix media upload js files not always available on cpt 412fe80
jrfnl commented Mar 22, 2014

Thank you for that! I've send in pull request #922 using your suggestion, but loading the media files a little more selectively (only on pages where the metabox will be displayed). I hope this will fix it just as well.
Closing this issue in favour of the pull request.

Ref: to get to the right article straight away: http://kingpro.me/article/tutorials/custom-image-uploader-for-plugins-using-the-wordpress-native-functions/

@jrfnl jrfnl closed this Mar 22, 2014
@jrfnl jrfnl added bug Metabox labels Mar 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment