Skip to content

Commit 7507883

Browse files
committed
fix video width and height read src
1 parent db148a1 commit 7507883

File tree

7 files changed

+19
-13
lines changed

7 files changed

+19
-13
lines changed

dist/js/lightbox-plus-jquery.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10098,7 +10098,6 @@ return jQuery;
1009810098
// Hide most UI elements in preparation for the animated resizing of the lightbox.
1009910099
Lightbox.prototype.changeImage = function (imageNumber) {
1010010100
var self = this;
10101-
1010210101
this.disableKeyboardNav();
1010310102
var $image = this.$lightbox.find('.lb-image');
1010410103

@@ -10116,10 +10115,14 @@ return jQuery;
1011610115

1011710116
if (self.album[imageNumber].video) {
1011810117
$video.attr('src', self.album[imageNumber].link);
10119-
self.sizeContainer($video.width(), $video.height());
10118+
var $videoWidth = parseInt($video.attr('width'));
10119+
var $videoHeight = parseInt($video.attr('height'));
10120+
self.sizeContainer($videoWidth, $videoHeight);
1012010121
if (!$hasVideoNav) {
1012110122
$lbContainer.addClass('lb-video-nav');
1012210123
}
10124+
this.currentImageIndex = imageNumber;
10125+
return;
1012310126
} else {
1012410127
$video.attr('src', '');
1012510128
if ($hasVideoNav) {
@@ -10195,7 +10198,6 @@ return jQuery;
1019510198
// Animate the size of the lightbox to fit the image we are showing
1019610199
Lightbox.prototype.sizeContainer = function (imageWidth, imageHeight) {
1019710200
var self = this;
10198-
1019910201
var oldWidth = this.$outerContainer.outerWidth();
1020010202
var oldHeight = this.$outerContainer.outerHeight();
1020110203
var newWidth = imageWidth + this.containerPadding.left + this.containerPadding.right + this.imageBorderWidth.left + this.imageBorderWidth.right;

dist/js/lightbox-plus-jquery.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/lightbox-plus-jquery.min.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/lightbox.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@
283283
// Hide most UI elements in preparation for the animated resizing of the lightbox.
284284
Lightbox.prototype.changeImage = function (imageNumber) {
285285
var self = this;
286-
287286
this.disableKeyboardNav();
288287
var $image = this.$lightbox.find('.lb-image');
289288

@@ -301,10 +300,14 @@
301300

302301
if (self.album[imageNumber].video) {
303302
$video.attr('src', self.album[imageNumber].link);
304-
self.sizeContainer($video.width(), $video.height());
303+
var $videoWidth = parseInt($video.attr('width'));
304+
var $videoHeight = parseInt($video.attr('height'));
305+
self.sizeContainer($videoWidth, $videoHeight);
305306
if (!$hasVideoNav) {
306307
$lbContainer.addClass('lb-video-nav');
307308
}
309+
this.currentImageIndex = imageNumber;
310+
return;
308311
} else {
309312
$video.attr('src', '');
310313
if ($hasVideoNav) {
@@ -380,7 +383,6 @@
380383
// Animate the size of the lightbox to fit the image we are showing
381384
Lightbox.prototype.sizeContainer = function (imageWidth, imageHeight) {
382385
var self = this;
383-
384386
var oldWidth = this.$outerContainer.outerWidth();
385387
var oldHeight = this.$outerContainer.outerHeight();
386388
var newWidth = imageWidth + this.containerPadding.left + this.containerPadding.right + this.imageBorderWidth.left + this.imageBorderWidth.right;

dist/js/lightbox.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/lightbox.min.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/lightbox.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@
283283
// Hide most UI elements in preparation for the animated resizing of the lightbox.
284284
Lightbox.prototype.changeImage = function (imageNumber) {
285285
var self = this;
286-
287286
this.disableKeyboardNav();
288287
var $image = this.$lightbox.find('.lb-image');
289288

@@ -301,10 +300,14 @@
301300

302301
if (self.album[imageNumber].video) {
303302
$video.attr('src', self.album[imageNumber].link);
304-
self.sizeContainer($video.width(), $video.height());
303+
var $videoWidth = parseInt($video.attr('width'));
304+
var $videoHeight = parseInt($video.attr('height'));
305+
self.sizeContainer($videoWidth, $videoHeight);
305306
if (!$hasVideoNav) {
306307
$lbContainer.addClass('lb-video-nav');
307308
}
309+
this.currentImageIndex = imageNumber;
310+
return;
308311
} else {
309312
$video.attr('src', '');
310313
if ($hasVideoNav) {
@@ -380,7 +383,6 @@
380383
// Animate the size of the lightbox to fit the image we are showing
381384
Lightbox.prototype.sizeContainer = function (imageWidth, imageHeight) {
382385
var self = this;
383-
384386
var oldWidth = this.$outerContainer.outerWidth();
385387
var oldHeight = this.$outerContainer.outerHeight();
386388
var newWidth = imageWidth + this.containerPadding.left + this.containerPadding.right + this.imageBorderWidth.left + this.imageBorderWidth.right;

0 commit comments

Comments
 (0)