-
Notifications
You must be signed in to change notification settings - Fork 841
Social: Generate AI image for media from the sidebar #46147
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
base: trunk
Are you sure you want to change the base?
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
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 🤖 🔴 Action required: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so: Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Social plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
bd6fa0d to
0876eee
Compare
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.
It simply works good 👌
I had a couple of questions below - will approve once we discuss them, but in general everything works good!
| // Use 'media-library' as the source since the AI image is uploaded to the media library | ||
| updateJetpackSocialOptions( { | ||
| media_source: 'media-library', | ||
| attached_media: [ { id, url, type: 'image/png' } ], |
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.
Can we assume it's always image/png?
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.
Yes - AI-generated images are always PNG (they're returned as base64-encoded PNG from the AI service). Added a comment to clarify. e4d1448
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.
Alright, I see that now.
What I would propose here is to support the parameter mime_type in the function - to be coherent with WPMediaObject type in handleAiImageSelect(), with mime being optional and defaulting to image/png.
While I see that it's AI code that isn't considering other types, and that it might be replaced soon by Image Studio, it's good to be prepared for the correct object (or at least typed) to reach the input of this function. Otherwise, we end up with a hardcoded logic that requires a refactor - and I'm not sure whether all AI providers produce the png same as DALL-e.
I've run Claude to backtrack where it comes from:
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.
Done in efc7a83
| media.push( { | ||
| type: attachedItem.type, | ||
| url: attachedItem.url, | ||
| 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.
Doesn't the attachedItem have the alt text? Should we maybe set one here?
I would assume that AI generated image has the alt, as of the description of what is happening on the image 🤔
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.
Good catch. Simplified the code to always fetch from the entity record, which includes alt_text from the media library. However, the AI image generation flow doesn't currently set alt text on the media item when saving - that would require changes in ai-client. Worth tracking as a follow-up?
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.
Perhaps worth tracking - but I also understand they are working on this Image Studio, right?
Definitely better to keep it as it comes - instead of building our own logic that might become a bottleneck
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.
Yes they are, so not sure if it's worth fixing before that
projects/js-packages/publicize-components/src/components/social-previews/use-post-data.js
Outdated
Show resolved
Hide resolved
projects/js-packages/ai-client/src/components/ai-image/general-purpose-image.tsx
Show resolved
Hide resolved
robertsreberski
left a comment
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.
Code looks good to me, works great as well!
Just last comment about making sure the typing in consistent with what we already have in Publicize
|
|
||
| // Handle AI image selection | ||
| const handleAiImageSelect = useCallback( | ||
| ( { id, url, mime_type }: { id: number; url: string; mime_type?: string } ) => { |
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.
Should we use WPMediaObject type here, rather than introducing inline custom typing?
Closes SOCIAL-253
Fixes SOCIAL-240
Proposed changes:
This is a PoC sitting on top of Social: Add the new media selection UI #46085, that adds the support to create images with AI from our new media selector.- I cleaned it up, now it's ready for revieewReused the generic AI modal from ai-client, and integrated it into our media selector section
Testing instructions:
Prerequisites:
wpsh > add_blog_sticker( 'jetpack-social-unified-ui-v1', null, null, <your-blog-id> );projects/js-packages/publicize-components/src/components/form/index.tsxnegatesiteHasFeature( features.UNIFIED_UI_V1 )so you have the old modalTesting:
CleanShot.2025-12-04.at.11.54.08.mp4