_image_captionation.js 780 Bytes
jQuery(function($) {

    var capationize = setInterval(function() {
        var found = false;
        jQuery('.wp-block-image:not(.captionized)').each(function() {
            found = true;
            var img_width = jQuery(this).find('img').width();
            if(img_width != '0') {
                var _bottom = jQuery(this).find('figcaption').innerHeight();
                jQuery(this).find('figcaption').css('bottom', -_bottom);
                if($('.post-template-default').length == 0) {
                    jQuery(this).find('.cap-wrapper').css('width', img_width);
                }
                jQuery(this).addClass('captionized');
            }
        });
        if(!found) {
            clearInterval(capationize);
        }
    }, 500);

});


export { };