Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Media Command

Media Command Laravel Package

wp-cli/media-command

WP-CLI media command for WordPress: import local files or STDIN as attachments, set featured images, regenerate thumbnails in bulk, replace existing attachment files, fix EXIF orientation, and list all registered image sizes—streamlining media management from the command line.

View on GitHub
Deep Wiki
Context7

WP-CLI Media Command adds media management to WP-CLI, letting you maintain the WordPress media library from the shell. It imports files from local paths or STDIN as attachments (optionally setting featured images), regenerates thumbnails after theme or size changes, and replaces attachment files while keeping IDs and metadata intact.

  • wp media import — import local files, URLs, or STDIN as attachments
  • wp media regenerate — rebuild thumbnails for all or selected images, with optional cleanup of stale sizes
  • wp media image-size — list every registered image size with dimensions and crop mode
  • wp media fix-orientation — correct EXIF rotation on photos
Frequently asked questions about Media Command
Is wp-cli/media-command compatible with Laravel?
No. wp-cli/media-command is a WP-CLI extension built for WordPress and relies on WordPress core APIs such as wp_insert_attachment and wp_generate_attachment_metadata. Laravel does not include WordPress, so you cannot use it as a native Composer media library. You can only use it indirectly by running WP-CLI against a WordPress installation and calling that process or service from Laravel.
Can I install wp-cli/media-command with Composer in a Laravel project?
Not as a Laravel package. The supported install path is the WP-CLI package installer, for example wp package install wp-cli/media-command, run in an environment with WP-CLI and WordPress available. Adding the Composer package to a Laravel composer.json will not register wp media commands in Laravel.
What Laravel versions does wp-cli/media-command support?
It has no Laravel version support matrix because it does not target Laravel. Its compatibility surface is WP-CLI and WordPress, so you should check the package's WP-CLI and PHP requirements instead of Laravel 10 or Laravel 11 support. In a Laravel app, any version compatibility comes from your bridge service, not from this package.
How do I run wp media regenerate from a Laravel job or queue?
You can dispatch a Laravel queue job that invokes WP-CLI through a controlled process wrapper or an HTTP microservice, then handles output and failures. Do not call shell_exec directly in controllers; wrap it in a service with timeouts, retries, and input validation. Bulk thumbnail regeneration can be long-running, so queueing and progress tracking are important.
What are Laravel-friendly alternatives for image imports and thumbnail regeneration?
Use Laravel-native media and image packages such as spatie/laravel-medialibrary, intervention/image, or direct Imagick/GD calls. You would reimplement the needed import, thumbnail regeneration, and orientation logic rather than depending on WordPress. This avoids the WP-CLI and WordPress runtime dependency but requires development work.
How can a Laravel app integrate with WordPress media without a full rewrite?
Run WP-CLI in a dedicated container or service and expose only the commands you need through a narrow API, or build a small WordPress plugin endpoint that wraps the media operations. Laravel then calls that service instead of loading WordPress code directly. Keep authentication, file-path validation, and error handling in the bridge layer.
Does wp-cli/media-command work for headless WordPress or hybrid Laravel apps?
Yes, it can be useful in a headless WordPress setup because it operates on the WordPress install where media attachments live. Laravel would typically consume WordPress REST API data or call a WP-CLI service rather than executing the commands inside the Laravel process. This keeps WordPress as the media system of record while Laravel remains the application layer.
How should I test Laravel integration with wp-cli/media-command?
Mock the WP-CLI call behind an interface or service class and assert that your Laravel code sends the right command arguments and handles success and failure responses. If you use an HTTP wrapper, use Laravel's HTTP fake instead of running real WP-CLI during tests. Add tests for file-path sanitization and timeout handling.
What are the main production risks of using wp-cli/media-command with Laravel?
The main risks are high WordPress dependency, maintenance burden, performance overhead on bulk operations, security exposure from shell commands, and testing complexity. Mitigate by isolating WP-CLI behind a service, validating all inputs, queueing long jobs, caching results, and keeping a Laravel-native fallback plan. Treat it as an external integration, not a normal Laravel package.
How do I import attachments or fix image orientation from Laravel using this package?
You can proxy commands such as wp media import and wp media fix-orientation through a WP-CLI service or wrapper, passing validated file paths and attachment IDs. If you need pure Laravel processing, use Intervention Image or Imagick to import files and correct EXIF orientation yourself. Either way, validate uploads and avoid exposing raw command execution to user input.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo