Social: Add image focal point data model and picker in the media section#49580
Draft
gmjuhasz wants to merge 1 commit into
Draft
Social: Add image focal point data model and picker in the media section#49580gmjuhasz wants to merge 1 commit into
gmjuhasz wants to merge 1 commit into
Conversation
Contributor
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Contributor
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 4 files.
1 file is newly checked for coverage.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes SOCIAL-503
Proposed changes
jetpack_social_options(_wpas_options) post meta:image_focal_points: { [attachment_id]: { x, y } }— one point per image, keyed by attachment ID. Consumers look up the image they are processing; a missing key means unset. REST schema validates coordinates (0–1) viapatternPropertiesand rejects unknown keys.MediaFocalPointcomponent to the media section (v2), wrappingFocalPointPickerfrom@wordpress/components. It replaces the static preview for real image attachments and commits on drag end only, rounded to 2 decimals.use-post-meta(newimageFocalPointsvalue andupdateImageFocalPoint( attachmentId, point )helper). Hidden for SIG (attachment id 0) and video.social-image-focal-pointfeature (rolled out via a WordPress.com-side flag; sticker-driven, off everywhere by default). The data model is intentionally ungated.This is PR 1 of 4 for the focal-point based social image generation project (SOCIAL-422). Follow-ups render the point in social previews (SOCIAL-504), wire drag-to-adjust into the preview modal (SOCIAL-505), and serve focal-cropped og:image variants (SOCIAL-506).
Related product discussion/links
Does this pull request change what data or activity we track or use?
No. New post meta stores user-selected focal point coordinates per image; no new tracking events.
Testing instructions
Requires a site with paid Social features (the media section is gated on them) and the
social-image-focal-pointfeature. Until the wpcom flag PR deploys and a sticker is applied, you can test by temporarily returningtruefrom thesiteHasFeature( features.IMAGE_FOCAL_POINT )check inmedia-section-v2/index.tsx.jetpack build packages/publicizeand load a post in the block editor.wp.data.select( 'core/editor' ).getEditedPostAttribute( 'meta' ).jetpack_social_options.image_focal_pointsshould show{ <attachment_id>: { x, y } }with 2-decimal values, written only on release.false(default), the media section behaves exactly as on trunk.jetpack test js packages/publicizeandjetpack test php packages/publicizecover the picker visibility, map merging, and the REST schema round-trip/validation.