Drupal 9 image field migration

As you know, when creating image field there is an option to create a default image fallback. Image will be saved in public folder. The issue is that we cant export default image within configs, but that's ok for singlesite instances where you need to manually copy the image to production website from your dev env. Also you need to update the image manually again, if you changed it in configs.

Using https://www.drupal.org/project/config_default_image module will make it possible, but image should be located in public:// folder. Sabe problem again.

My solution is flexible and can use one image for all cases. I had to implement this because of multisite instance, where every website has own files and database, but the same codebase. 
We need to create custom formatter and provide image from module's folder. To achieve this we will use really old ongoing issue to implement additional stream wrappers for D10. Patching the core with https://www.drupal.org/files/issues/2021-12-15/1308152-395.patch will help to achieve the result. Issue url https://www.drupal.org/project/drupal/issues/1308152. It will add additional stream wrappers like module:// and theme://.
So after patching you need to create a custom Formatter to handle default images from your module. Actually it's possible to use an image from custom theme folder but additional settings should be implemented.
Add the image to my_module/images/default-image.png folder and select new formatter for your image.

Code posted on Gists ImageDefaultFallbackFormatter.php