At around line 175 change
$matches[0] = preg_replace('/\s*=\s*/', '=', substr($matches[0],0,strlen($matches[0])-2));
to be
$matches[0] = preg_replace('/\s*=\s*/', '=', substr($matches[0],0,strlen($matches[0])));
As the -2 will strip part of the image name by 2 characters.... i.e .jpg turns into .j
-Edward