Opened 10 years ago
Last modified 6 years ago
#32459 new enhancement
Send custom metadata alongside a file upload via the media uploader
Reported by: | danphilibin | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.2.2 |
Component: | Media | Keywords: | |
Focuses: | administration | Cc: |
Description
As WordPress has evolved into a very powerful CMS, responsive layouts and high-resolution screens are growing more and more common. It's not uncommon for large sites to register several additional image sizes, and adding 2X support doubles the number of images created behind the scenes.
It would be nice for plugins to be able to have more granular control over the sizes that are created when an image is uploaded.
An example: a company Team page features portraits for each employee. Only two sizes are needed: 250x250 and 500x500 (2x). Meanwhile, the rest of the site has nearly a dozen custom image sizes. When the portraits are uploaded, a dozen sizes are created, but only two are needed. Similarly, registering these two new sizes registers them for every image uploaded to the site.
In a plugin like Advanced Custom Fields, I'd like to be able to tell the uploader to skip all of the built-in sizes and hand-pick the sizes I do want to create.
In other words, a new set of sizes would need to be registered that aren't automatically included in the global set of image sizes, but are available for plugins to select and send to the uploader. The uploader could be given a special set of sizes when it's opened, and those special sizes can be fetched from the theme.
To be clear, I'm not talking about generating new image sizes when the theme requests them. This request is for overriding the sizes that the uploader applies to a new image.
I've explored the built-in functions and hooks and filters, but it doesn't appear there's a way to override the sizes that are created in the way I describe.
Change History (2)
#2
@
10 years ago
- Summary changed from Add a filter for overriding image sizes before uploading to Send custom metadata alongside a file upload via the media uploader
Thanks @rittesh.patel. intermediate_image_sizes_advanced
does indeed do part of what I'm looking for—modifying the default set of sizes.
However, I can't find a way to only apply that filter in certain circumstances when the upload is initiated. Is there a way to send additional data with a file when it's uploaded?
wp_handle_upload_prefilter
seems like a good place to examine an upload and determine whether to modify the sizes array, but I can't find a way to send custom data and have it show up in that filter.
I suppose a better summary of this request is gaining the ability to send custom metadata alongside a file upload.
Hi @danphilibin,
I think
intermediate_image_sizes
andintermediate_image_sizes_advanced
filters can fulfill your requirement.