Bind to WPSetAsThumbnail

Yes, on your 2nd question 🙂

From what I saw in set-post-thumbnail.dev.js, it appears that you only need to add a link/anchor with the wp-post-thumbnail class on it in your quick edit screen.

And you will get the image faded inside that link when the ajax request completes.

For alerting “bacon” after the ajax completes, this might work:

$('a.wp-post-thumbnail').ajaxComplete(function() {
  alert('bacon');
});


The ajaxComplete approach:

jQuery(document).ready(function($){

  $('a.wp-post-thumbnail').ajaxComplete(function(event, XMLHttpRequest, ajaxOptions) {

    // the image should be here
    // use something like $(XMLHttpRequest.responseText).find('img')
    console.log(XMLHttpRequest.responseText);

  });

});

You might need to check which ajax request this is, do console.logs for all arguments and search of the property that holds the ajax action name, which should be “set_post_thumbnail” or something…

Leave a Comment