[wp-trac] [WordPress Trac] #21819: Use an image size for custom headers instead of duplicating an attachment

WordPress Trac noreply at wordpress.org
Wed Mar 22 22:31:55 UTC 2017


#21819: Use an image size for custom headers instead of duplicating an attachment
-------------------------+-----------------------
 Reporter:  koopersmith  |       Owner:
     Type:  enhancement  |      Status:  assigned
 Priority:  normal       |   Milestone:  4.7.4
Component:  Customize    |     Version:  3.5
 Severity:  normal       |  Resolution:
 Keywords:  needs-patch  |     Focuses:
-------------------------+-----------------------

Comment (by westonruter):

 Replying to [comment:16 joemcgill]:
 > Alternately, we could add a new property like alternate_sizes which
 contain sets of edited versions of an attachment.

 This makes a lot of sense to me. It would eliminate having to keep track
 of two different attachment posts. Maybe instead of `alternate_sizes` it
 could be `variations` and then this could include a name (e.g.
 `custom_logo`) and then the value could contain the `width`, `height`,
 whether cropping was performed done, and so on. Essentially these would be
 ad hoc image sizes that would be specific to this one `attachment`.

 When opening the media manager, we'd need to pass in a specific variation
 name as being desired so that when an image is cropped it gets routed to
 that variation instead of creating a new attachment. It would be nice if,
 when re-selecting a previous image that was cropped for a given variation,
 if the cropper tool opened with the original full size image shown but
 with the cropper configured to have the same bounding box as was
 previously selected. If they Skip Crop, then the variation would be
 unchanged. If they Crop, then it would override the previous variation
 stored in meta and create a new file on disk.

 > Last idea (and probably the most straightforward) is to create a new
 attachment for custom logo/header crops, like we're currently doing, and
 set the post parent to the original attachment to keep the association. To
 keep from having duplicate images in the media library, we might be able
 to set some metadata on the parent attachment, which indicates that the
 file should be hidden from the media library if the file was uploaded from
 one of these upload and crop controls.

 So essentially this would be introducing the concept of derived images. It
 does seem a bit tricky in the media select frame what to do with the
 original vs the derived. Also, we'd need to figure out what to do when the
 original image is deleted. I was thinking this would be more feasible at
 first, but I like the idea of `alternate_sizes`/`variations` more.

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


More information about the wp-trac mailing list