mfpSetInterval = function(delay) {

                            if(_imgInterval) {
                                clearInterval(_imgInterval);
                            }
                            // decelerating interval that checks for size of an image
                            _imgInterval = setInterval(function() {
                                if(img.naturalWidth > 0) {
                                    mfp._onImageHasSize(item);
                                    return;
                                }

                                if(counter > 200) {
                                    clearInterval(_imgInterval);
                                }

                                counter++;
                                if(counter === 3) {
                                    mfpSetInterval(10);
                                } else if(counter === 40) {
                                    mfpSetInterval(50);
                                } else if(counter === 100) {
                                    mfpSetInterval(500);
                                }
                            }, delay);
                        }
Function that loops until the image has size to display elements that rely on it asap