Skip to content

Perform updates on secondary image mime types when original image is edited #158

@mitogh

Description

@mitogh

Scenario

When an image is uploaded into WordPress at least 2 mime types would be created according to with:

After the image completes the update into the media library, the image would be stored using at least 2 mime types, for this scenario let's use:

  • image/webp
  • image/jpeg

For simplicity, we are going to call webp the primary image format and jpeg the secondary image format.

After an image is uploaded edits can be performed against this image, when using the image editor (see attached image) or from within the Gutenberg editor.

2022-02-08_20-24

  • rotation
  • flip
  • crop

After an edit is performed in the original image the original sizes are stored inside of _wp_attachment_backup_sizes and the files preserved to allow a restore of the files in case required. Subsequent edits (if more than a single update is performed) would be stored in the _wp_attachment_backup_sizes keeping _wp_attachment_metadata data with the last edit so the image always reflect the last action performed by the user.

Recreate image in secondary image format for every edit

For every edit performed on the original image, a primary image format would be stored (WordPress default behavior).

So the questions come into place: Should the secondary image format recreate the same edit format and keep the original secondary format the same way it happens with the primary image format.

This behavior is consistent with the primary image format. In case an image is requested with the secondary format the image would be displayed in the same way as the primary image format.(with the edits applied to the original image)

Notes

  • Image edits should include the suffix e-$id where $id is a 13 digit number specifically time() . rand( 100, 999 ) created by WP to reference any additional edit that is no longer relevant, the file name is important so WP can identify images that reference to edits and can be removed accordingly based on the definition and value of IMAGE_EDIT_OVERWRITE This suffix is also included as part of the image size name.

Metadata

Metadata

Assignees

Labels

[Plugin] Modern Image FormatsIssues for the Modern Image Formats plugin (formerly WebP Uploads)

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions