I'm including images with external links for src. Some of these images return 404 not found errors.

This block of code, starting at line 267 in views_slideshow_cycle.js causes the slideshow to break if the image is not found.

          if (settings.totalImages) {
            settings.loadedImages = 0;

            // Add a load event for each image.
            $(settings.targetId + ' img').each(function() {
              var $imageElement = $(this);
              $imageElement.bind('load', function () {
                Drupal.viewsSlideshowCycle.imageWait(fullId);
              });

              // Removing the source and adding it again will fire the load event.
              var imgSrc = $imageElement.attr('src');
              $imageElement.attr('src', '');
              $imageElement.attr('src', imgSrc);
            });
          }

Comments

redndahead’s picture

For now you can turn off the setting "Wait for all images to load" Then this code will not run.

linclark’s picture

For anyone coming to this issue, the "Wait for all images to load" setting is under "View Action Advanced Options".

Bevan’s picture

Title:broken image links break slideshow» Broken image URI breaks slideshow

Is it possible to detect the failure of image-loading? I know this can be done with XHRs, but I have not tried with images. E.g. jQuery('img', context).bind('error', function() {...}). If that works we should use that to handle this scenario and load the slideshow once all images either have loaded or loading has failed.

Alternatively, it was suggested in #1154738: Timeout for "wait for images to load" setting that there could simply be a timeout period of a couple of seconds, after which the slideshow is loaded anyway, ignoring of the loaded state of any unloaded images.

#1154738 has been marked duplicate.

weri’s picture

Subscribe.

redndahead’s picture

Status:Active» Needs review
StatusFileSize
new3.54 KB

Can someone please test this patch. It adds a timeout to the image loading of, by default, 2 seconds. You can adjust it in the slideshow settings page. Is 2 seconds too long or too short for the default?

redndahead’s picture

StatusFileSize
new3.54 KB

This fixes a typo

Bevan’s picture

I am not convinced this is any better than simply disabling the feature altogether.

I briefly reviewed and the patch looks good, but could use more comments explaining what the setTimeout() is doing.

Do most browsers trigger the "load" event when A) the HTTP response headers have been received and parsed, or B) when image file's header data has loaded and the browser knows how big the image is? Or do they C) trigger the "load" event only once all data has loaded?

If A or B, then I think 2 seconds is good. Perhaps on the low side though. 5 or 10 might be better.
If C, then no time period is suitable, since the image could be 1 or 1000 kb, and thus take split seconds or a minute to load.

I believe it is A or B, but I am not sure. It is probably inconsistent in older browsers.

redndahead’s picture

It waits until everything is loaded. http://stackoverflow.com/questions/5070347/when-exactly-does-onload-occur

So what should be the correct action? It seems we need a timeout no matter how big that image may be. I think the site admin would need to realize what the possible sizes may be and adjust the timeout accordingly.

Bevan’s picture

Hmm. In that case I am in favour of deprecating the feature entirely, or at least disabling it by default (or is it already disabled by default?). But I am not the maintainer, so that's just my 2 cents.

redndahead’s picture

The feature fixes an issue where the width and height doesn't get calculated because the image is not loaded. So we are in a catch 22. Disabling by default is a possibility, but I think a timeout is still needed somewhere. Or else finding something that fires when the image is not found.

redndahead’s picture

Priority:Normal» Critical
redndahead’s picture

Status:Needs review» Fixed
StatusFileSize
new5.37 KB
new6.87 KB

I went ahead with the idea I had at the beginning. At most a 3 second delay before just going. Here are the patches I committed.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

rerooting’s picture

This doesn't seem to be working for me. I'm getting these kinds of errors in the console log in IE9:

[cycle] options not found, "prev/next" ignored

I tried fiddling with the forced initialization setting that you provided, but it still does not start rotating, nor does it rotate with thumbnails or arrows. Possibly I'm on the wrong issue?

loopy1492’s picture

Issue summary:View changes

This was working before and now it is broken again. Did someone use the wrong Git branch or something?

Thanks for the temporary solution of turning off "Wait for images to load". That worked, but I'd like to see this fixed soon because sometimes my users are on a slow, state government internet connection.

Thanks.