Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9018847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:38:05+00:00 2026-06-16T04:38:05+00:00

I have a situation where we are progressively showing higher and higher quality images

  • 0

I have a situation where we are progressively showing higher and higher quality images to a user as they download.

The logic looks like this:

3 Image formats : low quality (5-8kb), large (60-80kb), highres (150-250kb).

  1. Check if large or high res photo is cached if so simply initially show cached version and FINISH.
  2. If not load low quality image and display to the user straight away.
  3. precache large image and change img.src once it has loaded.
  4. Check users window size if it exceeds a certain threshhold, precache highres image and change img.src on load.

Everything works beautifully.

However during the high res download if a user clicks to go to the next image, everything will of course get screwed up since we have set an event to occur onload when the previous highres image has loaded.

Essentially the onload event is occurring after the user has already clicked to go onto the next image, meaning that the NEW image is getting replaced with the old one.

What I need to do is be able to cancel the function whenever a user changes to the next photo.

The function looks something like this:

(function(index){
        $(highresimage).imagesLoaded(function(){
                    setTimeout(function(){
                        self.cache.image = $(highresimage).appendTo(self.cache.imagewrap);
                        self.cache.photos[index]['highresloaded'] = true;
                        setTimeout(function(){
                        self.cache.imagewrap.children('img').first().remove();
                        self.cache.image.css({
                            'left':'',
                            'position':'relative'
                        });
                        },10);
                    },200);
        });
})(index);

So I need to be able to programmatically cancel the $(highresimage).imagesLoaded(function(){});

What would be the best way of achieving this?

Thanks in advance.

EDIT: Please note in my example we are actually cloning the image, changing the src, adding it to the dom, leaving a few ms then removing the old image. This is down to a bug in Firefox which causes flashing when changing the src of high resolution images. As horrible as it is, removing the ugly timeouts makes the experience far worse for the user in Firefox. They are there for a reason. 😛

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:38:07+00:00Added an answer on June 16, 2026 at 4:38 am

    If you save the setTimeout in a variable, you can use clearTimeout to cancel it. In theory, the loading of the images should be aborted.

    var timeout = setTimeout(do_something, 1000); // create
    
    clearTimeout(timeout); // cancel
    

    After looking at the source code of imagesLoaded(), I can’t find anything that allows you to cancel that function too which is a bit of a bummer 🙁

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have situation like this: user submits form with action='/pay' in '/pay' I have
i have situation like this: class IData { virtual void get() = 0; virtual
I have situation like this: Range formulaCells = range.SpecialCells(XlCellType.xlCellTypeFormulas); And I want to iterate
I have situation like this: I am doing my own mvc project in visual
I have situation like this: I have commited files a,b,c,d.Now i found that by
If I have situation like below, where I success. handle image upload and store
I have a situation like this: public abstract class BaseClass { public abstract string
I have situation where in the regular expression is something like this: ^b?A+b?$ So
I have situation like this: <ul> <li> <a href=#>Link 1</a> <ul> <li><a href=>Sub link</a></li>
I can't make git push origin B. I have situation something like this _____________________________________

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.