Codeinwp / Nivo-Slider-jQuery

Nivo Slider - The Most Awesome jQuery Image Slider
http://docs.themeisle.com/article/485-getting-started-with-the-nivo-slider-jquery-plugin
MIT License
1.25k stars 605 forks source link

empty captions still displayed #373

Open BHEADRICK opened 10 years ago

BHEADRICK commented 10 years ago

nivo-caption div is displayed whether there is content to be displayed or not, and I have an overlay background on it with some animation, so if I have a slide with no caption, I have this empty overlay.

I tried using the callbacks to make the bg transparent if it doesn't have any content, but none of them trigger at an appropriate time for that.

serip88 commented 8 years ago

you need edit jquery.nivo.slider.js to solved this problem function processCaption

var processCaption = function(settings){
        var nivoCaption = $('.nivo-caption', slider);
        if(vars.currentImage.attr('title') != '' && vars.currentImage.attr('title') != undefined){
            var title = vars.currentImage.attr('title');
            if(title.substr(0,1) == '#') title = $(title).html();   
            if(nivoCaption.css('display') == 'block'){
                setTimeout(function(){
                    nivoCaption.html(title);
                }, settings.animSpeed);
                if(!title){
                    nivoCaption.stop().fadeOut(settings.animSpeed);  
                }
            } else {
                nivoCaption.html(title);
                if(nivoCaption.contents().length){
                    nivoCaption.stop().fadeIn(settings.animSpeed);    
                }
            }
        } else {
            nivoCaption.stop().fadeOut(settings.animSpeed);
        }
    }
UVLabs commented 7 years ago

@selul we should patch this I think I see it in our themes. User above seem to have posted the solution but that file doesn't seem to be present anymore

friimaind commented 7 years ago

@UVLabs It's strange... The function "processCaption" is present on non-minified JS https://raw.githubusercontent.com/Codeinwp/Nivo-Slider-jQuery/master/jquery.nivo.slider.js

Anyway the fix of @serip88 works flawlessly, thank you!