Jump to content

Recommended Posts

I'm a newbie.

 

My site imports images into a gallery using a combination of mls_search (Wordpress plugin no longer online with no support) and galleria. All images are in subdir by a mls number, and named like this - mlsnumber-1.jpg, mlsnumber-2.jpg, etc.

 

The site only uses 10 images at a time, though more than 10 may be present in the image subdir.

 

Here is my issue. The images are not displayed in the order they should. Instead of mlsnumber-1.jpg, mls-number-2.jpg, etc., the first image will be mlsnumber-10.jpg, mlsnumber-11.jpg, etc. If there are less than 20 images in the sub dir, say 15, the images will continue to mlsnumber-15.jpg, then to mlsnumber-6.jpg, mlsnumber-7.jpg, etc. The files "-1.jpg" through "-5.jpg" are ignored.

 

Here is how it looks on a sample page. There were 15 images in the subdir.

 

--

 

    <ul id="images" style="display:none;height:400px;padding:0;">

              <li><img src="/photos/88571/image-88571-10.jpg"></li>

              <li><img src="/photos/88571/image-88571-11.jpg"></li>

              <li><img src="/photos/88571/image-88571-12.jpg"></li>

              <li><img src="/photos/88571/image-88571-13.jpg"></li>

              <li><img src="/photos/88571/image-88571-14.jpg"></li>

              <li><img src="/photos/88571/image-88571-15.jpg"></li>

              <li><img src="/photos/88571/image-88571-6.jpg"></li>

              <li><img src="/photos/88571/image-88571-7.jpg"></li>

              <li><img src="/photos/88571/image-88571-8.jpg"></li>

              <li><img src="/photos/88571/image-88571-9.jpg"></li>

          </ul>

 

--

 

Is this a common issue? I understand why "-10.jpg" would go first, but why would "-1.jpg" through "-5.jpg" be ignored?

 

That's just the way numbers are 'alphabetized' when stored in string type data. To allow it to sort in the manner you want it to, you'd need to pad the number with 0 so they are in the 01, 02, 03, . . . 10, 11, 12, etc. format.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.