Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alt added to image overlay in js #365

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 16 additions & 12 deletions js/lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
this.alwaysShowNavOnTouchDevices = false;
this.wrapAround = false;
}

// Change to localize to non-english language
LightboxOptions.prototype.albumLabel = function(curImageNum, albumSize) {
return "Image " + curImageNum + " of " + albumSize;
Expand Down Expand Up @@ -59,7 +59,7 @@
Lightbox.prototype.build = function() {
var self = this;
$("<div id='lightboxOverlay' class='lightboxOverlay'></div><div id='lightbox' class='lightbox'><div class='lb-outerContainer'><div class='lb-container'><img class='lb-image' src='' /><div class='lb-nav'><a class='lb-prev' href='' ></a><a class='lb-next' href='' ></a></div><div class='lb-loader'><a class='lb-cancel'></a></div></div></div><div class='lb-dataContainer'><div class='lb-data'><div class='lb-details'><span class='lb-caption'></span><span class='lb-number'></span></div><div class='lb-closeContainer'><a class='lb-close'></a></div></div></div></div>").appendTo($('body'));

// Cache jQuery objects
this.$lightbox = $('#lightbox');
this.$overlay = $('#lightboxOverlay');
Expand All @@ -71,7 +71,7 @@
this.containerRightPadding = parseInt(this.$container.css('padding-right'), 10);
this.containerBottomPadding = parseInt(this.$container.css('padding-bottom'), 10);
this.containerLeftPadding = parseInt(this.$container.css('padding-left'), 10);

// Attach event handlers to the newly minted DOM elements
this.$overlay.hide().on('click', function() {
self.end();
Expand Down Expand Up @@ -135,8 +135,10 @@
function addToAlbum($link) {
self.album.push({
link: $link.attr('href'),
title: $link.attr('data-title') || $link.attr('title')
title: $link.attr('data-title') || $link.attr('title'),
alt: $link.attr('data-alt')
});

}

// Support both data-lightbox attribute and rel attribute implementations
Expand Down Expand Up @@ -166,7 +168,7 @@
}
}
}

// Position Lightbox
var top = $window.scrollTop() + this.options.positionFromTop;
var left = $window.scrollLeft();
Expand Down Expand Up @@ -197,12 +199,14 @@
preloader.onload = function() {
var $preloader, imageHeight, imageWidth, maxImageHeight, maxImageWidth, windowHeight, windowWidth;
$image.attr('src', self.album[imageNumber].link);
$image.attr('alt', self.album[imageNumber].alt);


$preloader = $(preloader);

$image.width(preloader.width);
$image.height(preloader.height);

if (self.options.fitImagesInViewport) {
// Fit image inside the viewport.
// Take into account the border around the image and an additional 10px gutter on each side.
Expand Down Expand Up @@ -244,12 +248,12 @@
// Animate the size of the lightbox to fit the image we are showing
Lightbox.prototype.sizeContainer = function(imageWidth, imageHeight) {
var self = this;

var oldWidth = this.$outerContainer.outerWidth();
var oldHeight = this.$outerContainer.outerHeight();
var newWidth = imageWidth + this.containerLeftPadding + this.containerRightPadding;
var newHeight = imageHeight + this.containerTopPadding + this.containerBottomPadding;

function postResize() {
self.$lightbox.find('.lb-dataContainer').width(newWidth);
self.$lightbox.find('.lb-prevLink').height(newHeight);
Expand All @@ -273,7 +277,7 @@
Lightbox.prototype.showImage = function() {
this.$lightbox.find('.lb-loader').hide();
this.$lightbox.find('.lb-image').fadeIn('slow');

this.updateNav();
this.updateDetails();
this.preloadNeighboringImages();
Expand Down Expand Up @@ -330,15 +334,15 @@
location.href = $(this).attr('href');
});
}

if (this.album.length > 1 && this.options.showImageNumberLabel) {
this.$lightbox.find('.lb-number').text(this.options.albumLabel(this.currentImageIndex + 1, this.album.length)).fadeIn('fast');
} else {
this.$lightbox.find('.lb-number').hide();
}

this.$outerContainer.removeClass('animating');

this.$lightbox.find('.lb-dataContainer').fadeIn(this.options.resizeDuration, function() {
return self.sizeOverlay();
});
Expand Down
4 changes: 2 additions & 2 deletions js/lightbox.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.