Skip to content
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

Cannot bulk import media #114

Open
crtl opened this issue Aug 26, 2019 · 6 comments
Open

Cannot bulk import media #114

crtl opened this issue Aug 26, 2019 · 6 comments

Comments

@crtl
Copy link

crtl commented Aug 26, 2019

Bug Report

I have around 2.6k images in a subdirectory inside wp-content/uploads/product_images.
I tried to import them but get the following error:

$ wp media import ./product_images/*.png --skip-copy
/.../Composer/vendor/wp-cli/wp-cli/bin/wp: line 45: /c/xampp/php/php: Argument list too long
/.../Composer/vendor/wp-cli/wp-cli/bin/wp: line 45: /c/xampp/php/php: No error

The command evaluates the blob and just appends all files as arguments for the php command which seems to be too long for php to handle.

@schlessera
Copy link
Member

@crtl The ./product_images/*.png bit in your command is already expanded by your shell in this case. The shell will expand this while examining the filesystem and then pass on a file list that matches this pattern to the actual tool being called, like so:

$ wp media import ./product_images/image1.png ./product_images/image2.png ./product_images/image3.png ... --skip-copy

So there's nothing that WP-CLI can do here, as the problem already occurs before you're even hitting the WP-CLI tool.

However, I notice now that the documentation says the command would support glob capabilities, which doesn't seem to be the case as far as I can see from the source code. If that would be the case, you could provide the "unglobbed" string to wp media import by quoting it, which I don't think works right now:

wp media import './products_images/*.png' --skip-copy

So a solution to this problem would be to add actual globbing support to the command and then handling the expansion within PHP memory.

@crtl
Copy link
Author

crtl commented Sep 9, 2019

The solution would be to support passing directory names and a recursive option to the command.

@schlessera
Copy link
Member

Directory names are not precise enough for this. Actual globbing would be preferable, and PHP already supports this out of the box, so it'd be easier to implement as well.

@crtl
Copy link
Author

crtl commented Sep 9, 2019

How can you decide whats precise and what not.
The command is pretty useless if you can only upload a limited amount of images because for small amounts you can just use the normal media upload in the admin dashboard.

@schlessera
Copy link
Member

The goal is to make this more useful by allowing you to control what to include at the WP-CLI level, instead of relying on the shell.

But adding folders and a recursive option is both more complicated and less flexible than just passing the provided argument through the PHP glob() function.

@bgoewert
Copy link

Was getting an error while attempting to bulk import.
Warning: Unable to import file 'images/*.webp'. Reason: File doesn't exist.

Then I realized that I had the path in quotes. The docs show an example for bulk imports with an unquoted path. Removing the quotes fixed the issue.

It's not a huge deal, but I was expecting the string path to work too.

Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants