| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
The class is in charge of performing operations to an image as if a user is performing those actions from the image editor but from the BE. This class is a utility class to be used from within the test context to mimic the user behavior of performing edits into an image.
When an image is edited the `sources` properties is going to be backup with the rest of the sizes properties, however that's not the case for the `full` size which is a virtual type and the top level `sources` would be moved into the backup metadata. When the image is restored any edited image available in the sources array would be removed before the restore takes place. The `sources` property for the `full-orig` would be placed at the top level `sources` with the rest of the metadata.
There was a problem hiding this comment.
@mitogh Left a few comments. High-level summary:
Sorry, something went wrong.
This would be handled once #158 is merged so the current approach can be adjusted accordingly.
When an image is edited using a target other than the all and the thumbnail make sure the `success` method returns the correct value.
Due to the only value that is not correctly stored is the top level sources attributes this now is stored in a separate meta value. Stored in `_wp_attachment_backup_sources` Logic was added to handle scenarios where only the thumbnail or all images except the thumbnail are modified.
|
Thanks for this review @felixarntz just updated this PR based on your feedback, let me know in case you have any additional comments or feedback. |
Sorry, something went wrong.
There was a problem hiding this comment.
@mitogh Left a few follow-up comments, I still have some open questions, and a few small nit-picks.
Sorry, something went wrong.
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Move the hooks for the update right into the place where they are actually used.
There was a problem hiding this comment.
@mitogh This looks great now from a functionality perspective! I left a few comments on cleaning up a few things, we can simplify some code and reuse the function instead of rewriting it twice.
The main point of feedback here is that we also should do an extra security check to ensure we're updating the correct attachment.
Sorry, something went wrong.
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
The `backup_sizes` parameter was not used so it can be safely removed from the code execution.
Reuse the hook as now is stored in a variable, so it can be reused in both hooks.
There was a problem hiding this comment.
@mitogh Awesome work!
cc @adamsilverstein for incorporating this into the core patch (in there we can do it without that hook weirdness present here)
Sorry, something went wrong.
There was a problem hiding this comment.
Nice work, @mitogh! Added some comments with minor improvements. Please, let me know whether it makes sense to you.
Sorry, something went wrong.
Co-authored-by: Eugene Manuilov <manuilov@google.com>
Co-authored-by: Eugene Manuilov <manuilov@google.com>
Co-authored-by: Eugene Manuilov <manuilov@google.com>
Co-authored-by: Eugene Manuilov <manuilov@google.com>
Make sure the code performns in a more structured way
There was a problem hiding this comment.
LGTM! Thanks, @mitogh.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Fixes #228
Relevant technical choices
Usage of _sources metadata key
A _sources property is stored to hold the top-level sources for the full image size when an image is edited, after the backup is updated the _sources property would be moved into the appropriate full size inside of the backup metadata and the temporarily _sources property would be removed from the attachment image.
This key is used so when the metadata is updated we still have a reference to the previous sources values to the full size image when the image is edited. This is not the case for the rest of real sizes, this is only the case for full sizes.
When the image is restored the sources property is populated again from the backup metadata if the full-orig has the sources property.
Removal of edited images
When an image is edited and restored any edited version of the images are removed if IMAGE_EDIT_OVERWRITE is defined as a truthy value.
Checklist