Skip to content

Commit be9fc6e

Browse files
committed
Add alt tags to main image items when parsed (references Codeinwp/pull/410)
1 parent b791fb2 commit be9fc6e

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

jquery.nivo.slider.js

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,20 @@
117117

118118
// Set first background
119119
var sliderImg = $('<img/>').addClass('nivo-main-image');
120-
sliderImg.attr('src', vars.currentImage.attr('src')).show();
120+
sliderImg.attr({
121+
src: vars.currentImage.attr('src'),
122+
alt: vars.currentImage.attr('alt')
123+
}).show();
121124
slider.append(sliderImg);
122125

123126

124127
// Detect Window Resize
125128
$(window).resize(function() {
126129
slider.children('img').width(slider.width());
127-
sliderImg.attr('src', vars.currentImage.attr('src'));
130+
sliderImg.attr({
131+
src: vars.currentImage.attr('src'),
132+
alt: vars.currentImage.attr('alt')
133+
});
128134
sliderImg.stop().height('auto');
129135
$('.nivo-slice').remove();
130136
$('.nivo-box').remove();
@@ -221,7 +227,10 @@
221227

222228
// Event when Animation finishes
223229
slider.bind('nivo:animFinished', function(){
224-
sliderImg.attr('src', vars.currentImage.attr('src'));
230+
sliderImg.attr({
231+
src: vars.currentImage.attr('src'),
232+
alt: vars.currentImage.attr('alt')
233+
});
225234
vars.running = false;
226235
// Hide child links
227236
$(kids).each(function(){
@@ -275,9 +284,7 @@
275284
}
276285

277286
$('.nivo-slice', slider).height(sliceHeight);
278-
sliderImg.stop().animate({
279-
height: $(vars.currentImage).height()
280-
}, settings.animSpeed);
287+
sliderImg.stop().animate({ height: $(vars.currentImage).height() }, settings.animSpeed);
281288
};
282289

283290
// Add boxes for box animations
@@ -315,9 +322,7 @@
315322
}
316323
}
317324

318-
sliderImg.stop().animate({
319-
height: $(vars.currentImage).height()
320-
}, settings.animSpeed);
325+
sliderImg.stop().animate({ height: $(vars.currentImage).height() }, settings.animSpeed);
321326
};
322327

323328
// Private run method
@@ -339,13 +344,22 @@
339344
// Set current background before change
340345
if(!nudge){
341346
settings.onNextSlide.call(this);
342-
sliderImg.attr('src', vars.currentImage.attr('src'));
347+
sliderImg.attr({
348+
src: vars.currentImage.attr('src'),
349+
alt: vars.currentImage.attr('alt')
350+
});
343351
} else {
344352
if(nudge === 'prev'){
345-
sliderImg.attr('src', vars.currentImage.attr('src'));
353+
sliderImg.attr({
354+
src: vars.currentImage.attr('src'),
355+
alt: vars.currentImage.attr('alt')
356+
});
346357
}
347358
if(nudge === 'next'){
348-
sliderImg.attr('src', vars.currentImage.attr('src'));
359+
sliderImg.attr({
360+
src: vars.currentImage.attr('src'),
361+
alt: vars.currentImage.attr('alt')
362+
});
349363
}
350364
}
351365

0 commit comments

Comments
 (0)