Fix #313. Repair broken image extension detection regex.

I failed at using the right function for the test.
This fixes the code.