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 7933161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:14:39+00:00 2026-06-03T21:14:39+00:00

I have a folder with images in it and I’m loading those images using

  • 0

I have a folder with images in it and I’m loading those images using jQuery. This code:

$(function () {
    var i=1;
    for (i=1;i<=50;i++){
        var curImg = "blog/wp-content/uploads/" + i + ".jpg";
        var img = new Image();         
        $(img).load(function () {                                 
             $(this).hide();
             $('#loader').removeClass('loading')
                         .append(this);
             $(this).fadeIn();
         }).error(function () {})                            
         .attr('src', ''+curImg+'');                    
    }
});

works fine for smoothly loading 50 images from this folder. I am trying to do 2 things:

  1. I want to add a link like this: <a href='blog/wp-content/uploads/" + i + ".jpg' class='picLink'> to each individual image. I have tried using .wrap in my .load function here, but that isn’t working for me. This just creates a nest of links (e.g. <a><a></a></a>).
  2. Currently this finds the first 50 photo’s, starting at number 1, and loads them. But if more photo’s are added they won’t be found, and the oldest will always be first. I would like it to find all photo’s in the folder and print the newest (highest number) first. It can be presumed that there won’t be more than, say, 4000 photo’s. So would it be possible to do this loop in reverse, start at 4000, check if that photo exists and work down and just load photo’s that exist in the folder?

Thanks in advance for any help, I hope the question is clear enough!

  • 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-03T21:14:40+00:00Added an answer on June 3, 2026 at 9:14 pm

    For 1. you can do something like this fiddle

    $(function () {
        var i=1;
        for (i=1;i<=50;i++){
            var curImg = "blog/wp-content/uploads/" + i + ".jpg";
            var img = new Image();         
            $(img).load(function () {                                 
                 $(this).hide();
                 $('#loader').removeClass('loading')
                             .append($('<a href="'+this.src+'"></a>').append(this));
                 $(this).fadeIn();
             }).error(function () {})                            
             .attr('src', ''+curImg+'');                    
        }
    });
    

    Also they may not be in order as some images may take longer to load than others.

    For 2. I think you should get the image count server-side and inject it into the for loop something like,

    for (i=<?php echo $count; ?>; i > <?php echo ($count>50?$count-50:0); ?>; i--){
    

    assuming you’re using php, where $count represents the amount of images in the folder.

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

Sidebar

Related Questions

I have a folder C:\Images which has a some images. This folder is not
I have a folder named Common/Images/Photounavailable.jpg . Is this right way of refering to
i am using wix 3.0.i have a folder name images.so i want to copy
I have a folder with images, which should be accessed only using HTTPS. How
In the images folder i have a notfound.php file with <?php header('Content-type: image/png'); $im
I have a folder of images, from 10 to 200, a webpage, a jquery
I have a folder called images in the sdcard of my emulator. This folder
In a folder images I have a thousand xml files.Those filenames I want them
I have a folder of images over 4MB - let's call this folder dsc_big/
I'm having trouble with my Apache Web Server. I have a folder (htdocs\images) where

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.