Automattic / Automattic/studio
Redirect local media references to an existing production site
- Dominant language
- TypeScript
- Stars
- 517
- Forks
- 95
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 162
Description
### What
I would love to be able redirect media references in a local environment to a corresponding production site. This would allow me to develop new features for an existing site without needing to download all of the sites /uploads directory. Basically what WordPress VIP allows with their local dev environment https://docs.wpvip.com/vip-local-development-environment/add-media-content/
### Why
Developing features for an existing site is much easier if you can have an up-to-date copy of the site's database and media in the local environment. The database isn't usually too big, but the media can frequently be huge. Needing to download all of that for local development is a huge pain and takes up a lot of hard drive space. Just redirecting references to the local environment's uploads directory to the url of the existing production site lets you have access to the media in your local environment without needing to download everything.
### How
To use the wpvip dev environment as an example, when an existing database is synced to a local dev environment, a search and replace is performed to replace references to the production site url with the url of the local environment. At this time, the user can define a media redirect URL—usually the url of the existing production site. If a reference to a media file in the local environment returns a 404—because the uploads directory wasn't downloaded—it will be redirected to the url provided by the user as the media redirect url, connecting it to the media hosted on the live production site.
Contributor guide
Assessment
This issue has not been assessed yet.