Make WordPress Core

Opened 2 years ago

Last modified 11 months ago

#44867 new enhancement

image editor: save modified image as a new copy

Reported by: drzraf Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.2
Component: Media Keywords: has-patch
Focuses: administration Cc:


WordPress allows multiple image sizes to be defined by a theme : they will affect how hard-crop/soft-crop is being used.

Sometimes no autocropping is desirable because editors want to care themselves about it.
For example blog posts having two images ratios (thumbnail for listing, 3:1 for wide-width header).
Giving the possibility to derive one image from the other is very interesting : it avoid uploading two different images but still gives editor ability to do fine-tuned cropping.

For this to work the image editor must be able to save a modified image as a COPY of the original image.

Would an implementation be accepted?


Attachments (6)

0001-44867-image-editor-save-modified-image-as-a-new-copy.patch (3.6 KB) - added by drzraf 2 years ago.
patch v1
0002-44867-handle-new-image-size.patch (1.2 KB) - added by drzraf 22 months ago.
improvement: if cropping as a copy, correctly change corresponding metadata
fullpatch-v2-44867-image-editor-save-modified-image-as-a-new-copy.patch (3.3 KB) - added by drzraf 22 months ago.
patch v2
fullpatch-v3-44867-image-editor-save-modified-image-as-a-new-copy.patch (3.3 KB) - added by drzraf 18 months ago.
updated for WP5
fullpatch-v4-44867-image-editor-save-modified-image-as-a-new-copy.patch (2.8 KB) - added by drzraf 10 months ago.
v4 compatible with 5.3.2
fullpatch-v5-44867-image-editor-save-modified-image-as-a-new-copy.patch (2.8 KB) - added by drzraf 10 months ago.

Download all attachments as: .zip

Change History (17)

#1 @drzraf
2 years ago

  • Keywords has-patch added

Closing image editor triggers a imageEdit.close() does this._view.back().
But there is no way that I know to refresh media editor (from this._view) afterwards, but that would be needed to show the newly created attachment.

Other elements open to discussion:

  • The image image suffix (-e<timestamp>) may not fit (it'd mess with images backups).
  • The title substitution (appending the hardcoded string -mediacopy)
  • The fact that upload directory is kept to the value of the original file (instead of putting <current-year>/<current-month>)
Last edited 2 years ago by drzraf (previous) (diff)

#2 @mukesh27
2 years ago

  • Focuses administration added

#3 @drzraf
2 years ago

image-edit.php: @nacin @adamsilverstein ?

#4 follow-up: @adamsilverstein
2 years ago

For this to work the image editor must be able to save a modified image as a COPY of the original image.

@drzraf can you explain what you are trying to do?

i don't think i understand why this is required - why you need a copy of the image (can you use the original itself)? can you do what you need with custom crop/sizes?

#5 in reply to: ↑ 4 @drzraf
2 years ago

Replying to adamsilverstein:

For this to work the image editor must be able to save a modified image as a COPY of the original image.

@drzraf can you explain what you are trying to do?

Editor wants to add a rectangular 3:1 image to a blog post. He uploads one adequate image as an image field.

Then he wants to also provide a square image as a (optional) thumbnail (be it for search-listing, OpenGraph image, ... ...):

  • Solution 1: Use the same header image as the thumbnail.
  • => Thumbnail is auto-cropped (center, North-East, ...) but this is probably useless because the (square) region of interest is not there and must be selected by hand.
  • Solution 2: Upload the image a second time and crop it by hand.
  • => ok, but could be better
  • Solution 3: Crop it locally using a desktop application, then upload
  • => ok, but could be better

If user crops the original image (rather than a copy), he looses the possibility to use the original rectangular one as a 3:1 header image.

I think it makes sense to allow editors to create multiple derivatives from one image without having the upload the original file multiple times.

#6 @adamsilverstein
2 years ago

Thanks for explaining. Typically you would have predefined crops/aspect rations in your theme for different image placements, however I can see a use case for the ability to duplicate an existing media item, giving you a copy you can then do what you want with. Would a "duplicate image" function in the medial library fit your needs?

This feature might make more sense as something a plugin can provide.

#7 @drzraf
2 years ago

Yes, a duplicate media would be fine.
That way editors could quickly define various flavors of one image, cropping the way they want in order to get extract the best portion according to their human feeling.

I'd personally prefer to see a "duplicate" button in the media editor because that's the place/moment people would look for it so that would improve efficiency:
Just click "duplicate" then immediately start editing/cropping the copy.

NB: I think a kind of medias relationship should be maintained somewhere (post meta?)

#8 @drzraf
22 months ago

Dear WP team,
could you advise how to move forward on this?

  • As patch shows, there is no apparent way to implement this as a plugin.
  • There is a missing bit about editor since, I don't know how to refresh the media browser listing (because a new file is added) when image editor is closed.
Last edited 22 months ago by drzraf (previous) (diff)

22 months ago

improvement: if cropping as a copy, correctly change corresponding metadata

#9 @pento
22 months ago

  • Version trunk deleted

#10 @drzraf
18 months ago

  • Version set to trunk

#11 @drzraf
11 months ago

Patch needs reroll for 4.3, but before doing that or engaging myself in indefinite rerolls, I'd really like to get more comments from upstream about this feature, implementation and inclusion.

Note: See TracTickets for help on using tickets.