alleyinteractive / stage-file-proxy

Mirror (or header to) uploaded files from a remote production site on your local development copy. Saves the trouble of downloading a giant uploads directory without sacrificing the images that accompany content.
24 stars 6 forks source link

Add a way of setting what the production URL is #18

Open vaccinemedia opened 6 months ago

vaccinemedia commented 6 months ago

Description

I'm assuming that because of the name "Stage File Proxy" that this plugin is supposed to work the same as the Drupal module by the same name?

The way that the Drupal module works is that you enter what the production / live URL is in the settings. You can also add what the files folder is in case the production server has them in a different location for whatever reason.

Then whenever you browse to a page on the locally hosted version of the website (on a VM for example with website-name.local as the URL) and an image is missing from the local files directory, it downloads the source file from the live website based on what you have the production / live URL set as. It does not download the generated images such as thumbnails and other image sizes as they can be generate on the local server. It only downloads the main image file.

The setting for what the production URL is is so that the website knows what the URL is of the production website, otherwise, how would the module know where to pull the images from?

Currently, because I can't find where the production URL is set, no images are downloaded from the production website and they all show as missing images.

The URL of all of these images is of course: http://website-name.local/wp-content/uploads/YEAR/MONTH/name-of-image.jpg

Use Case

When a user browses to a page on a locally hosted version of the website, any missing images are pulled from the production website based on what the URL is of the production website.

Based off the description, a missing image with the URL: http://website-name.local/wp-content/uploads/YEAR/MONTH/name-of-image.jpg

Will make the website look for the image at: https://live-website-address.com/wp-content/uploads/YEAR/MONTH/name-of-image.jpg

Where https://live-website-address.com is the value of "Production URL" in the settings.

And if it finds it, download it and store it in the local files directory. Now the image is no longer missing.

mogmarsh commented 6 months ago

@vaccinemedia currently settings are set using the WordPress CLI. So in your example above you would run wp option set sfp_url https://live-website-address.com/wp-content/uploads/

vaccinemedia commented 6 months ago

That's great! Thanks for the reply. I'll try this out asap.