I think maybe this file used to call createThumbanilFromSource() in more than once place.  Or maybe that function was just copied from some other file here.  Feel free to merge that code into generateNewPreview().