mn-martin Posted September 22, 2016 Share Posted September 22, 2016 Hello, today I've tried the following: Use .htaccess to rewrite the url conditionally if an image file was not found. Rewrite target was http://www.this-is-the-live-system.com/site/assets/files/$1 I guess that would work out great. Unfortunately Processwire checks to see if the file exists and outputs an error message in the Page Editor. An option to disable this check would be great. (Similar to $config->debugIf = '::1'; or something) It would be great being able to just use the live database locally without broken images all over the place. I guess this might be a simple good enough solution for most use cases. Link to comment Share on other sites More sharing options...
Yannick Albert Posted September 22, 2016 Share Posted September 22, 2016 I think this should work (not tested): # Load media files from production server if they don't exist locally # http://rzen.net/serve-missing-media-production-apache-nginx/ <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f [NC] RewriteRule ^(.*\.(js|css|png|jpe?g|gif|ico)) http://example.com/$1 [NC,P,L] </IfModule> ...if this doesn't work for you, try php: /** * Load media files from production server if they don't exist locally * * https://processwire.com/talk/topic/5550-local-development-and-remote-assets/?p=54385 * https://processwire.com/talk/topic/4127-can-assets-folder-be-moved-to-another-domainsubdomain/?p=50150 */ $wire->addHookAfter('Pagefile::url', function ($event) use($config) { $path = str_replace($config->urls->root, $config->paths->root, $event->return); if (!is_file($path)) { $event->return = str_replace($config->urls->root, 'http://example.com/', $event->return); } }); Link to comment Share on other sites More sharing options...
mn-martin Posted September 23, 2016 Author Share Posted September 23, 2016 Hello Yannick Albert, thank you for the suggestions. I'm sure these will work for the frontend. Unfortunately i see the same results as with my other attempts. The backend will just return error messages telling me that the files do not exist. (Screenshot) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now