Opened 15 years ago
Closed 10 years ago
#12493 closed enhancement (maybelater)
Filter $bits in wp_upload_bits()
Reported by: | Viper007Bond | Owned by: | josephscott |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0 |
Component: | Upload | Keywords: | has-patch mobile needs-docs |
Focuses: | Cc: |
Description
It'd be nice if there was a filter on $bits
in wp_upload_bits()
to allow plugins to modify uploads coming in from XML-RPC. Resizing, watermarking, etc. are all example uses for this filter.
Since it's a simple filter, perhaps it could be slipped into 3.0.
Attachments (2)
Change History (15)
#2
follow-up:
↓ 3
@
15 years ago
If we are going to do this have you looked at adding a corresponding filter for uploads done via AtomPub?
#3
in reply to:
↑ 2
@
15 years ago
Replying to josephscott:
If we are going to do this have you looked at adding a corresponding filter for uploads done via AtomPub?
AtomPub uses wp_upload_bits()
too, doesn't it?
#4
@
15 years ago
I have thoroughly tested this tonight via XML-RPC and it works awesome. I don't have an AtomPub client though, but I don't see why it wouldn't work as it's the same kinda thing.
#7
follow-up:
↓ 8
@
10 years ago
- Component changed from XML-RPC to Upload
Moving this outside of XML-RPC since it's also used inside the function wp_generate_attachment_metadata() since [27863].
For the reason this ticket was created I would say close it since I'm unsure we want to filter the original. Image sizes could be done with a custom WP_Image_Editor. That said, adding the filter is easy to do.
#8
in reply to:
↑ 7
;
follow-up:
↓ 10
@
10 years ago
Replying to markoheijnen:
For the reason this ticket was created I would say close it since I'm unsure we want to filter the original.
Actually that's exactly what I wanted to do when it came to watermarking, otherwise the original image could be downloaded from the site. However that makes a tiny watermark on the thumbnails so really the thumbnails should be watermarked on their own by this imaginary plugin and then the original file overwritten with a watermarked version afterwards.
It gets complicated fast but can you ever have too many filters? :)
At the very least allowing resizing massive images, or using crushing techniques, seems like a useful case for this.
#9
@
10 years ago
- Milestone changed from Future Release to 4.1
Curious how crushing bits looks like but the filter could be a great way to limit the size of the original.
Let's see if we can get this included in 4.1 :)
#10
in reply to:
↑ 8
@
10 years ago
Replying to Viper007Bond:
Yep. Anything that makes it more difficult to be backwards compatible with future changes is usually a good example of a bad filter.
This one seems fairly harmless, but it looks like demand for it is particularly low. Also, actually messing with the bits is kind of low level, no? I'd kind of prefer an action similar to wp_handle_upload (which is actually a filter) that lets you know where the file is upon completion. Unfortunately wp_handle_upload() is not a shining example of hooks as it uses that weird overrides stuff from probably the 1960s.
#11
@
10 years ago
Didn't thought about an action but I do like that idea. Less change to break stuff when filtering and also if you want to use WP_Image_Editor, it only can receive a file anyway.
To clarify, yes this can be done after the file is saved to the filesystem, but then the thumbnails must be regenerated and the meta data updated. A big hassle.