iPad/iPhone error on preloading image
I'm having a bit of an issue preloading an image, and setting up stuff when it is loaded. I use the onLoad (or the jQuery $("img").load()-thingy) event to detect when the image is loaded. This works fine in most browsers, exept when im trying it on an iPad/iPhone. Somehow it just throws the onError event (which has NO description WHAT SO EVER on what the error is!). But when I, in my onError Event, redirect to the image, it shows just fine. Very strange and can't seem to figure out what is causing it.
Some code:
if( !limg ) {
var load = function($img) {
setTimeout(function() {
var src = $img.attr("src");
video.trigger(filmLoad, [s]);
if (((src.indexOf(url) >= 0 && urlIsString) || !urlIsString)
&& src.indexOf("_low.") >= 0)
{
$img开发者_如何学编程.attr(
"src",
urlIsString
? url.replace("_low.", "_high.")
: set.film.url.high);
still = stillIsString
? still.replace("_low.", "_high.") : set.film.still.high;
}
}, 0);
};
limg = s.loaderimg = $("<img>")
.appendTo(video)
.css({opacity: 0, position: "absolute", left: "-200em"})
.load(function(e) { load($(this)); })
.error(function(e) { if(e.target.complete) { load($(this)); } })
.src("src/to/my/image.jpg");
}
If you are using a .manifest
file, you need to put the urls of the images in it.
Hi just to answer my own question:
I found out that the iPad has a limit in how large images it will download, and as my images was very large (dimensions wise) it simply didn't download them. The images is actually small filmstrips, with a height over 14000 pixel and a width around 600 pixel. So the iPad threw an error, when loading them and then skipped downloading. I tried to make the image more square, so that the image wasn't so high, but it still threw an error. the solution was to split the images up into smaller chunks, as i discovered that the iPad allowed images with dimensions around 600x6000 pixel. Therefore i split the filmstrip up in smaller images with dimensions around 600x4500 pixel, which worked pretty well.
So in conclusion: If the iPad refuses to download an image, it might be to big, either byte wise or dimensions wise.
精彩评论