I'm having trouble figuring out how to build a gallery for a list of wallpapers that, as a whole, don't have sequential naming schemes. One example would be:
image/img1_800.jpg
image/img1_1024.jpg
image/img1_1280.jpg
image/img2_800.jpg
etc.
Other conventions might include (though not simultaneously)
image/img1_800x600.jpg
image/img1_1024X768.jpg
image/img1_1280x1024.jpg (notice the two changing number sets)
as well as,
image/img1_s.jpg
image/img1_m.jpg
image/img1_l.jpg (notice the use of non-sequential letters)
In the past I've had to either build separate galleries for each resolution listed, or make an absolutely crazy large gallery with thousands of invalid links. I'm sure there's a simple solution, but as previously stated, I've zero experience with java. Thank you for you time and patience.
PS - Also, if it's not to much trouble, could you briefly explain why the answer you give works, so that I don't have to ask again if other similar naming schemes show up, and I can just re-tailor it to the task. Thanks again.
Need help building galleries with non-sequential names
Need help building galleries with non-sequential names
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
- Giorgio Maone
- Site Admin
- Posts: 9524
- Joined: Wed Mar 18, 2009 11:22 pm
- Location: Palermo - Italy
- Contact:
Re: Need help building galleries with non-sequential names
You can use an URL pattern like this:
After entering it, in the "JavaScript Functions" tab you'll find a new label() function entry.
Define it this way:
This function will allow you to replace numeric indexes (in this case in the range 0-2) passed as the first arguments with arbitrary strings, passed as an array in the second argument (in this case ["800x600","1024x768","1280x1024"]).
Code: Select all
http://example.com/image/img[1-10]_[label([0-2], ["800x600","1024x768","1280x1024"])].jpg
Define it this way:
Code: Select all
var index = arguments[0];
var types = arguments[1];
return types[index];
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.14) Gecko/20110218 Firefox/3.6.14
Re: Need help building galleries with non-sequential names
Thank you very much! it worked like a charm. So all I've got to do is change what's in the quotes and/or the number rage, say [0-4] for larger sets?
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
- Giorgio Maone
- Site Admin
- Posts: 9524
- Joined: Wed Mar 18, 2009 11:22 pm
- Location: Palermo - Italy
- Contact:
Re: Need help building galleries with non-sequential names
YesJavaNoob wrote:Thank you very much! it worked like a charm. So all I've got to do is change what's in the quotes and/or the number range, say [0-4] for larger sets?

Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15