Moved thumbnail helper so it can be used as a plugin