Jump to content

Image gallery skipping files by name (10.jpg before 1.jpg)


robrob73

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.