pdclark / uploads-by-proxy Goto Github PK
View Code? Open in Web Editor NEWFor local development: Automatically load images from the production version of wp-content/uploads if they are missing locally.
For local development: Automatically load images from the production version of wp-content/uploads if they are missing locally.
Multisite support basically comes down to three things:
class-404-template.php#L92
UBP checks to see if the requested $path
from $_SERVER['REQUEST_URI']
contains $uploads['basedir']
with ABSPATH
stripped out. So, for example, when requesting an image:
/wp-content/uploads/2012/10/image.jpg
$uploads['basedir']
without ABSPATH
on a single site is:
wp-content/uploads
which exists in the requested path, so it passes.
On multisite, the requested $path
would be:
/files/2012/10/image.jpg
But $uploads['basedir']
would be something like:
/wp-content/blogs.dir/3/files/
(where "3" is a blog ID)
So they don't match up. The check needs to be revised to accomidate multisite uploads directory path rewrites.
class-404-template.php#L41
When an image is found, it's downloaded and saved to the local uploads directory. The download method, like allow_path, makes the assumption that the path to save the image to matches the path the image was requested from. In multisite, this isn't the case.
For example, single site:
image requested from: http://site.com/wp-content/uploads/2012/10/image.jpg
image saved to: ABSPATH.'/wp-content/uploads/2012/10/image.jpg'
But multisite:
image requested from: http://site.com/subsite/wp-content/uploads/2012/10/image.jpg
image saved to: ABSPATH.'/wp-content/blogs.dir/3/files/2012/10/image.jpg'
And "subsite" could also be a subdomain (subsite.site.com), or a mapped domain name. (subsite.com)
I haven't tested Nacin's final version of this in the 3.5 betas, but I'm pretty sure it's slated for release. Basically, in 3.5, there they'll be using wp-content/uploads/sites instead of wp-content/blogs.dir. wp_upload_dir() should account for this, but it of course needs to be tested, and the solutions for #1 and #2 need to be agnostic to whether they're running on 3.4- or 3.5+
To test any of these, you'd need to comment out the hook for requiring multisite to activate. But maybe you already did that? I was surprised to hear you activated the plugin on a multisite at all. Did it let you do it on the master site?
If filename from uploads directory contains Unicode characters, infinite loop will occur.
This happens on Windows, not sure for Linux.
To fix this, two things needs to be changed in class-404-template.php
file.
In function get_local_path()
replace line
$this->local_path = $requested_path;
with
$this->local_path = urldecode($requested_path);
Then, in function download()
add snippet
if(strcasecmp(substr(PHP_OS, 0, 3), 'WIN') == 0){
$abspath = iconv('UTF-8', 'WINDOWS-1252', $abspath);
}
before line
$saved_image = $wp_filesystem->put_contents.....
All the images seem to work but mp4 files are failing, is there anything i can do to resolve this?
The extension doesn't seem to be working. Is it still compatible with the current release of WordPress?
I've defined 'UBP_SITEURL', 'UBP_LIVE_DOMAIN' and 'UBP_IS_LOCAL', but not getting anything to work.
Hello,
I have added this to my local on different projects before it works fine if I am grabbing images from live sites, but if I am trying to get images from a production/staging server from my local computer, it doesn't work.
I believe this is because the production/staging server is username and password protected.
Is there a way to overcome these credentials (I have the logins) so I can call those images?
Kind regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.