robrob73 Posted January 13, 2011 Share Posted January 13, 2011 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? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 13, 2011 Share Posted January 13, 2011 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. Quote Link to comment Share on other sites More sharing options...
robrob73 Posted January 13, 2011 Author Share Posted January 13, 2011 I assumed that. Thank you for confirming. Is there any way around that? I'm having to deal with multiple subdirs of images that are imported from another database. Thank you for the response. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 13, 2011 Share Posted January 13, 2011 Other than renaming all of the files and changing all of the corresponding database entries, nothing comes to mind immediately . . . Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 13, 2011 Share Posted January 13, 2011 You would need to get the file names into an array and use - http://us3.php.net/natsort or http://us3.php.net/manual/en/function.natcasesort.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.