FIX Ensure resampled image links get updated when files are moved.

This is a fix for #1114. Still needs tests but would be good to get a second opinion on the solution first.