Run script after clicking Set Featured Image in Media

I think what you need is

(function(){
    var featuredImage = wp.media.featuredImage.frame();
    featuredImage.on('select', function(){
        var attachment = featuredImage.state().get('selection').first().toJSON();
        console.log(attachment);
    });
})();

The attachment object should have height and width properties.

Leave a Comment