Make WordPress Core

Opened 4 years ago

Last modified 4 years ago

#48477 new enhancement

Add a hook before creating image sub-sizes

Reported by: greglone's profile GregLone Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 5.3
Component: Upload Keywords: has-patch needs-testing 2nd-opinion needs-dev-note needs-refresh
Focuses: Cc:

Description

Since things are moving for media thumbnails lately, it could be a good time to add a hook that fires right before thumbnails are created.
It would allow plugins to perform operations on the main file for example.

Attachments (1)

48477.diff (753 bytes) - added by GregLone 4 years ago.

Download all attachments as: .zip

Change History (15)

@GregLone
4 years ago

#1 @SergeyBiryukov
4 years ago

  • Milestone changed from Awaiting Review to 5.3

Moving to the milestone for visibility.

#2 @jorbin
4 years ago

  • Milestone changed from 5.3 to 5.3.1

I chatted with @mikeschroder and we discussed that we want to spend some time ensuring that we get the parameters and placement correct for this, so bumping to the .1 release to allow time for the exploration.

#3 @GregLone
4 years ago

I understand, I'm late and we're close to the release. Thanks for considering it :)

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


4 years ago

#5 @marybaum
4 years ago

Ooh I like this!

#6 follow-up: @azaozz
4 years ago

  • Keywords reporter-feedback added

It would allow plugins to perform operations on the main file for example.

What would be the intended use there? Currently there are (at least) three hooks fired right after a file was uploaded:

These give full access to all aspects of handling an uploaded file. Do we really need a forth hook specific for images? :)

#7 in reply to: ↑ 6 ; follow-up: @GregLone
4 years ago

Replying to azaozz:

Currently there are (at least) three hooks fired right after a file was uploaded:

The idea is not to have a hook that triggers after a file is uploaded but, as the hook’s name suggests, before sub-sizes are created. The difference is that it can happen even if the file wasn’t just uploaded: when a plugin regenerates thumbnails for example.
Currently I’m also thinking adding one after the sub-sizes are created and recorded in the database, maybe at the end of wp_update_attachment_metadata(), with an additional context argument (create/update), like you suggested recently if I remember well.

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


4 years ago

This ticket was mentioned in Slack in #core-media by audrasjb. View the logs.


4 years ago

#10 in reply to: ↑ 7 @azaozz
4 years ago

  • Keywords reporter-feedback removed
  • Milestone changed from 5.3.1 to 5.4

Replying to GregLone:

Currently I’m also thinking adding one after the sub-sizes are created and recorded in the database, maybe at the end of wp_update_attachment_metadata(), with an additional context argument (create/update), like you suggested recently if I remember well.

Yeah, this can potentially be useful. At the same time I'd prefer not to "rush it" in 5.3.1. Perhaps better to confirm the use cases before adding the hooks. Then a good decisions can be made whether to pass context, etc.

Moving this to 5.4 perhaps pending a revised/updated patch.

#11 @GregLone
4 years ago

I agree, it will give us time to think a bit more about it.

#12 @davidbaumwald
4 years ago

  • Keywords needs-dev-note added

This will at least need a small call out in the misc Dev Notes once it lands in a cycle. Tagging as such.

This ticket was mentioned in Slack in #core by david.baumwald. View the logs.


4 years ago

#14 @davidbaumwald
4 years ago

  • Keywords needs-refresh added
  • Milestone changed from 5.4 to Future Release

This ticket still needs a final decision and a refreshed patch, and with 5.4 Beta 1 landing tomorrow, this is being moved to Future Release. If any maintainer or committer feels this can be included in 5.4 or wishes to assume ownership during a specific cycle, feel free to update the milestone accordingly.

Note: See TracTickets for help on using tickets.