Looks to me like it is going to compare the file extension against the first item in the list (.jpeg != .jpg) and return 0. This means it won't get a chance to try the second extension in the list.
Probably best to set a flag in the comparison and not return until all items in the extension list have been compared against the file extension.