Fix bug when exiting Media Viewer while image is loading

Which would cause the image to never appear, even when reopening
Media Viewer. The source of the issue was an uncaught exception in
ThumbnailWidth.

Unfortunately this cannot be covered by E2E because the image
loads too fast in that context, and cucumber/selenium doesn't
have time to catch the placeholder.

Change-Id: I9386f6e857a7974166ddb5eeb7ea731d943eddcf
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/450
This commit is contained in:
Gilles Dubuc 2014-04-16 13:58:18 +02:00
parent 9b1e756c3b
commit 9d51e534da

View file

@ -499,6 +499,12 @@
this.thumbnailPreloadQueue = this.pushLightboxImagesIntoQueue( function( lightboxImage ) {
return function() {
// viewer.ui.canvas.getLightboxImageWidths needs the viewer to be open
// because it needs to read the size of visible elements
if ( !viewer.isOpen ) {
return;
}
return viewer.fetchThumbnailForLightboxImage(
lightboxImage,
viewer.ui.canvas.getLightboxImageWidths( lightboxImage ).real