[wp-trac] [WordPress Trac] #49096: Allow updating attachments with new files

WordPress Trac noreply at wordpress.org
Fri Jan 3 09:46:11 UTC 2020


#49096: Allow updating attachments with new files
-------------------------+------------------------------
 Reporter:  joehoyle     |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  REST API     |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:  rest-api
-------------------------+------------------------------

Comment (by joehoyle):

 > The closest example we currently have in core that I can think of this
 similarly to how custom theme images—like headers and site icons—are
 created now as new attachments instead of updating files for an existing
 attachment.

 I think the closest example in core is the image editor, which mostly
 because it was built pre-rest-api doesn't have the image updating logic in
 an endpoint, but core does include this behaviour.

 > but I could also see this opening up problems where files are updated on
 existing attachment posts that container totally different metadata

 That's a good point, I had considered maybe limiting the mime type for
 example to the original attachment, but yes, by opening up an endpoint
 we'd probably be allowing more difference than the in-line PHP editing
 that is done in core currently.

 I think sooner or later, this will have to be included in the REST API. I
 think it's likely any future media editing even in the admin is likely to
 use the REST API, and we get a two for one by letting clients also use it.
 I don't know how the WordPress mobile app does this, but I assume it just
 doesn't let you edit images, which I think is probably not a great user
 experience.

 Editing an image for your site icon has the user expectation that you
 wouldn't destroy / replace the original image, but the "direct" editing of
 an attachment comes with the expectation you are actually editing "the
 thing".

 ---

 So, my "argument" :D is: this functionality already does exist in Core,
 it's just that Core doesn't need an endpoint to use it. By adding this to
 the REST API, we allow 3rd party image editing tools to be used with
 WordPress, and we also allow for future Core/Admin image editing to use
 the same endpoint.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49096#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list