Reputation: 2223
Does anybody know how to add an action when the featured image is being attached to a post? I searched around but I can't find what I need.
Upvotes: 0
Views: 1709
Reputation: 2223
Analyzing all the ajax calls I found that I can hook into the action get-post-thumbnail-html/
This is the answer:
jQuery(function ($) {
$(document).ajaxComplete(function (event, xhr, settings) {
if (typeof settings.data==='string' && /action=get-post-thumbnail-html/.test(settings.data) && xhr.responseJSON && typeof xhr.responseJSON.data==='string') {
// do whatever
}
});
});
Upvotes: 1