Skip to content

Add deferred() conversion option#3922

Merged
freekmurze merged 13 commits intospatie:mainfrom
ziadoz:deferred-conversion
Apr 28, 2026
Merged

Add deferred() conversion option#3922
freekmurze merged 13 commits intospatie:mainfrom
ziadoz:deferred-conversion

Conversation

@ziadoz
Copy link
Copy Markdown
Contributor

@ziadoz ziadoz commented Mar 14, 2026

This adds a deferred() media conversion option. This is handy if for example you wanted to do a quick conversion such as an avatar thumbnail which is used on the next page after upload.

$this->addMediaConversion('thumb')
    ->width(400)
    ->deferred();

I did think about using a single enum property, rather than toggling two boolean ones, but I didn’t want to break compatibility.

Note: There's a "Fix styling" CI commit that's changed a lot of files here that are unrelated to this PR.

@ziadoz ziadoz marked this pull request as ready for review March 14, 2026 18:21
@freekmurze
Copy link
Copy Markdown
Member

Could you add docs for this?

Could you also revert all the imports of the namespaces in the config file. I don't want it to start with a big chunk of imports.

@ziadoz
Copy link
Copy Markdown
Contributor Author

ziadoz commented Mar 16, 2026

@freekmurze I've added some documentation.

The style and formatting changes here were made by the pint.yml CI workflow, so even if I revert them I believe they will be reapplied automatically.

@ziadoz
Copy link
Copy Markdown
Contributor Author

ziadoz commented Mar 23, 2026

I've address an issue with defer() being available in Laravel 11 lowest versions.

Replace the em-dash phrasing with a comma. Add two short paragraphs:
one noting that deferred work runs inline in the same PHP process so
slow or numerous conversions are better queued, and one stating the
Laravel 11.23 minimum for the defer() helper.
Early-return when queueAll is set so the deferred and queued
predicates no longer need to thread the queueAll flag.
@freekmurze freekmurze merged commit a80f584 into spatie:main Apr 28, 2026
29 checks passed
@ziadoz ziadoz deleted the deferred-conversion branch April 28, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants