The reason behind this is the function ConfigurableMediaImages.arrayIntersect
. The problem here is that the function must take in two already sorted arrays. Unfortunately the theme does not guarantee this.
Making sure the two arrays are sorted before calling the method will fix this issue for my needs I ended up adding a new js file with the following code:
ConfigurableMediaImages.arrayIntersect = function (a, b) {
a.sort();
b.sort();
var ai = 0, bi = 0;
var result = new Array();
while (ai < a.length && bi < b.length) {
if (a[ai] < b[bi]) {
ai++;
}
else if (a[ai] > b[bi]) {
bi++;
}
else /* they're equal */
{
result.push(a[ai]);
ai++;
bi++;
}
}
return result;
};
There is also a gist that covers this problem. Plus you can see the function has been copied from stackoverflow but the not about being sorted has been removed.