Use regex to substitute image dimensions in template string