Background of the issue:
different domain per language
in wp-admin foo.fr/wp-admin default language is "fr" but current user has "wp-wpml_current_admin_language..." cookie with value "en"
when calling wp_get_upload_dir()['baseurl'] in wp-admin, the URL is the "en" (foo.com) domain instead of the current "fr" (foo.fr) domain
Symptoms:
The uploads URL in wp-admin is incorrect. I expected to see foo.fr/wp-content/uploads, but instead, I got foo.com/wp-content/uploads.
Questions:
Why is the uploads URL showing the 'en' domain instead of the 'fr' domain?
How can I ensure the uploads URL matches the current language domain?
I have set up a test install with different domains per language and everything looks to be working correctly. Let me outline my tests here.
1. Log in to the English site at hidden link
2. Upload an image to the English library (URL shows like: hidden link
3. Sync media to all languages and check the French library by changing the admin language switcher to French. URL still looks like: hidden link
but the file path for the French copy of the image is: hidden link
On the frontend of the site, switch to French. It keeps me logged in because I have the option to automatically log in and out set. I click the admin user bar to view the dashboard. Now, the backend looks like this: hidden link
Uploads looks like: hidden link
and the file path for the English image is: hidden link
and for French is: hidden link
So what I find is that changing the langauge using the admin language on the backend doesn't necessarily change the URL, but it is working as expected. Chagning the language on the frontend DOES change the URL and if you then access the backend, you will see the wp-admin with whichever language you visited last on the frontend.
If you would like to test my test site, let me know and I can share credentials and you can update your hosts file. If you are experiencing different results on your live site, please write out step by step what steps to take so I can confirm the steps. If the steps on your site are the same as mine with different results, then it could be a conflict with another plugin or theme and we will need to test minimal settings, which is best done in a staging site if you have one.