Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve image attributes when cropping a custom logo image #2441
Preserve image attributes when cropping a custom logo image #2441
Changes from 32 commits
66f9cc5
57c95ae
eaadcd3
0701c5a
3245151
4c5f314
37c0724
1007a0c
28b56b4
24128be
2493ce7
4209559
bb8b3f9
fdaa748
4a54866
f96f9d3
c55674c
854fe54
a4cb089
412e862
743688e
a2e8c86
a39a551
5d3b37d
de84052
0757d9b
06ecc30
8982741
e6261c9
9af19ec
e6be279
d8a1643
ca8fe3a
9e2a262
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bit of a nit-pick, but I think it would make sense to include this immediately in the associative array above, right after
post_title
andpost_content
, which would clarify the relationship of the three when reading the code. The default for this would need to be the empty string (''
), which is the default forwp_insert_post
(and thuswp_insert_attachment
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the feedback.
I intentionally didn't include it in the associative array.
Why? I prefer not to specify a default value if the task does not require that.
I prefer to let
wp_insert_attachment
decide what value to use as default.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a fair point. Works for me 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly to my above comment, we could integrate this into the associative array passed to
wp_insert_attachment
above, which would colocate it with the other other related data. Other than in my previous comment though, here it would be more about avoiding an extra call toupdate_post_meta
.We can use the
meta_input
key (supported bywp_insert_post
and thus also bywp_insert_attachment
) to pass this information, basically like$object['meta_input'] = array( '_wp_attachment_image_alt' => wp_slash( $original_attachment->_wp_attachment_image_alt ) )
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I absolutely agree. I didn't know
wp_insert_post
supports themeta_input
key.Fixed in 9e2a262
cc @hellofromtonya
I've implemented the change suggested in @felixarntz`s comment above. I tested it manually and it worked as intended. Unit tests also passed.
But if that change will require retesting all use cases manually, please let me know, and I will revert that change.
I also don't want to block this PR from getting merged.