Make the plugin work with any media storage

Remove assumptions that the images are stored on the server file system to work with plugins that provide alternative media storage.

For reference, see wp-admin/includes/image.php.