Support » Plugin: Post Thumbnail Editor » JS bug prevents uploading media in Page/Post editor

  • Resolved micahjm

    (@micahjm)


    Hi,

    This week I noticed that when I try to upload media on the Edit Page screen it fails. Essentially after clicking “Select Files” and choosing a file, nothing happens, or I get a 1/10th filled progress bar. When I deactivate this plugin, everything works again. I’ve swapped out WordPress versions 4.1, 4.1.1, and 4.1.2, and this bug occurs in each of them.

    It is due to a Javascript error in the following file:

    /wp-admin/load-scripts.php?c=1&load%5B%5D=hoverIntent,common,admin-bar,heartbeat,autosave,wp-ajax-response,jquery-color,wp-lists,quicktags,jquery-query,admin-comments,sug&load%5B%5D=gest,postbox,post,editor-expand,backbone,wp-util,wp-backbone,media-models,wp-plupload,mediaelement,wp-mediaelement,media-views,m&load%5B%5D=edia-editor,media-audiovideo,wp-playlist,mce-view,imgareaselect,image-edit,svg-painter,wp-auth-check,jquery-ui-menu,jquery-ui-au&load%5B%5D=tocomplete,word-count,editor,wplink&ver=4.1.2

    The error itself occurs on line 83 and the message (in Chrome) is:
    “Uncaught TypeError: Cannot read property ‘text’ of undefined”

    It occurs in this function:
    info:function(){var a,b=this.queue,c=0;b.length&&(a=this.queue.find(function(a,b){return c=b,a.get("uploading")}),this.$index.text(c+1),this.$total.text(b.length),this.$filename.html(a?this.filename(a.get("filename")):""))}

    I’ve done testing in Chromium (ubuntu) and Chrome for Safari. Hopefully the error info is helpful. Thanks for a great plugin.

    – Micah

    https://wordpress.org/plugins/post-thumbnail-editor/

Viewing 15 replies - 1 through 15 (of 30 total)
  • Plugin Author sewpafly

    (@sewpafly)

    Sorry to be that guy, but it’s working for me…

    If you could try enabling debugging (Settings → Post Thumbnail Editor) or specifically setting define('SCRIPT_DEBUG', true); in your wp-config.php, we might be able to get a better error message. (It should break all the load-scripts into individual script calls)

    Have you tried disabling all other plugins and only having PTE enabled? It could be a conflict between another plugin and PTE.

    This plugin prevented me from uploading images, too. I enabled debugging through wp-config and through the plugin settings like you mentioned above, but there’s no error reporting. This issue occurs specifically when you’re running the (Yoast) WordPress SEO plugin in tandem with this plugin. Disabling either WordPress SEO or Post Thumbnail Editor resolves the issue, but they currently are conflicting with each other somehow. We’re running the latest version of WP on WPE, which just got updated the other day, and that may have offset something, because we didn’t experience this problem before.

    Thanks, you were right, it’s due to a plugin conflict between Post Thumbnail Editor and WordPress SEO Premium (yoast.com). I’ve deactivated all plugins except these two, and the error only occurs when both are activated at the same time.

    The javascript error is the same, but more specifically it involves line 4320 of media-views.js, in the info function.

    Having this issue as well. I don’t know if the problem is with WordPress, PTE, or Yoast. I can tell that, for some reason, after you choose your file, the “ready” function on line 4274 of media-views.js is not firing, so the $index, $total, and $filename variables are not getting set, which is what is causing the error on line 4320 mentioned above. Unfortunately I can’t figure out the root cause of why that function isn’t firing properly.

    Plugin Author sewpafly

    (@sewpafly)

    Thanks for the debugging help!

    Unfortunately the free version doesn’t seem to cause the same conflict. As a workaround, you can disable the PTE post media library integration by commenting out one line (post-thumbnail-editor.php: 171). In order to use PTE with this line commented out, you can set a featured image (and then launch the PTE editor from there) or use the standalone media library.

    I’ll see if I can rewicker the media-library integration, but this is one place where wordpress has done a terrible job with documentation and hookability.

    Thanks for the workaround! We’re testing it now and it does seem to solve the problem. I feel your pain on the media library documentation, I spent all morning digging through that code 😛

    Yes, thanks for the workaround! Gotta love how we can all come together and troubleshoot stuff =)

    Woops, late to the party! I’m using the free version of WordPress SEO, same issue with uploading media through the post editor.

    As sewpafly suggested, uploading media still works if you use Media – Add New.

    Not in hurry to use PTE, will keep plugin disabled for now. cheers

    Thanks. This solved the same problem on my end as well.

    The same problem here. Fix it commenting out:

    /** For the “Edit Image” stuff **/
    /* Hook into the Edit Image page */
    //add_action(‘dbx_post_advanced’, ‘pte_edit_form_hook_redirect’);

    add this to your theme functions.php, might be easier.

    /*-----------------------------------------------------------------------------------*/
    /** temp fix for thumbnaileditor v. 2.4.4 upload error in page edit uploads **/
    /** In order to use PTE with this action removed, you can set a featured image (and then launch the PTE editor from there) or use the standalone media library. **/
    /*-----------------------------------------------------------------------------------*/
    remove_action('dbx_post_advanced', 'pte_edit_form_hook_redirect');

    Any news on a permanent fix?

    Thanks

    Plugin Author sewpafly

    (@sewpafly)

    I can’t duplicate it, so I can’t fix it. I’ll probably add an option to disable the media library integration in the next version so you don’t have to add code or comment anything out, but unless I can get access to a breaking version, this is as good as I can do.

    Some extra info… For me it occurs on a wp 4.1.4 network install in combination with wp-seo plugin version 2.1.1 network activated.
    If I have some time I will try to test more…

Viewing 15 replies - 1 through 15 (of 30 total)
  • The topic ‘JS bug prevents uploading media in Page/Post editor’ is closed to new replies.