-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to prevent remote fetches #39
base: master
Are you sure you want to change the base?
Conversation
This can be useful if the attachments from the source site already exist within the destination site -- say, by way of FTP or rsync -- and you just need the attachment records added to the database.
Just wanted to say thanks for creating this - it came in very handy while creating the Flickr-to-WordPress migration tool at https://github.com/ChrisHardie/flickr-to-wordpress (described in some more detail at https://chrishardie.com/2019/02/moving-photos-flickr-wordpress/ ). I appreciate it! |
@ChrisHardie You're very welcome! Glad you found it useful. Your photos site looks great! |
hmm looks like this patch no longer works... |
looks like the same functionality is now in place for the plugin, the import_allow_fetch_attachments filter. maybe. |
The functionality of that filter is that it skips importing attachments entirely. This PR is with the intention of skipping the remote-fetch of attachments, for when the attachment already exists on disk but not within the media library. So the file isn't created, but the WP_Post is. |
THIS is exactly my use-case. I'm would like to use WordPress Playground as a tool to not only show, but also edit & save demo-data. So I created a blueprint, that imports all data from a wxr inside a Github repo. After editing your imported content in Playground, it is exported as wxr and commited back to the repo. (That's the short version, of what's happening) New uploaded files, get also added to the repo with the final commit. But next time the Playground is started the import starts again, and that is the moment, where it would be absolutely use- and helpful, if we could rely on:
|
Hello — Figured I'd open this PR to see if there was any interest. If not, that's okay.
The use case is actually a real-world scenario I'm dealing with right now :)
I've got a site with over 2,000 attachments I'm trying to import into an existing site. To speed things up, I downloaded all the files inside the uploads directory to my local machine via FTP.
I then created an export on the source site (All content + Media) and then started an import on the destination site. Problem is, the destination site still wants to download all the files from the source site even though they already exist locally.
With this PR, a new constant for wp-config.php is introduced (
IMPORT_PREVENT_REMOTE_FETCH
) and when set to true thefetch_remote_file()
function is short-circuited to return an array of info on the locally existing file for the attachment. There is also animport_prevent_remote_fetch
filter that receives the value of the constant, the URL, and the attachment to provide more fine-tuned control.Looking forward to any feedback. Thanks!