Skip to content
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

Added toggle control to set any image as feature image if no feature image is set for post #65896

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

up1512001
Copy link
Member

What?

  • if the feature image is not set for the post then if someone checked the toggle control of the image to set it as a feature image then it will be set as a feature image for the post.

Why?

fixes #65889

How?

  • added toggle control in inspector control to Set this image as feature image.
  • if isFeatureImage attribute is set & post doesn't have a feature image then it will be set as a feature image for the post.

Testing Instructions

  • create a new post.
  • add image block, and check Set this image as feature image toogle control of settings to set this image as feature image.
  • check feature image of post.

Screenshots or screencast

Screen.Recording.2024-10-06.at.16.29.51.mov

@up1512001 up1512001 added [Type] Enhancement A suggestion for improvement. [Block] Image Affects the Image Block labels Oct 6, 2024
@up1512001 up1512001 self-assigned this Oct 6, 2024
Copy link

github-actions bot commented Oct 6, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: up1512001 <up1512001@git.wordpress.org>
Co-authored-by: paaljoachim <paaljoachim@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: scruffian <scruffian@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@paaljoachim
Copy link
Contributor

paaljoachim commented Oct 6, 2024

Nice job @up1512001 Utsav!

I like what I see but it needs a broader view. As there might also be some similar/associated issues that might need to be considered.

I will buzz the Gutenberg designers here: @WordPress/gutenberg-design
To get feedback on this PR.

@t-hamano
Copy link
Contributor

t-hamano commented Oct 7, 2024

Thanks for the PR!

There are a few concerns with the approach to running set_post_thumbnail() dynamically:

  • This will not work if the image source is a URL instead of media.
  • This will not work if the image is placed inside a query loop or in a single template.
  • If there are multiple images with "Set this image as feature image" enabled in the content, the first image will be set as the featured image, but the settings for the second and subsequent images will be ignored.
  • The featured image will not update until the image is actually rendered, i.e. until you save the post.

I think of this feature as an action button, not a toggle, so it should work like this:

  • The "Make featured image" button will only be displayed in the block toolbar if the block has access to the post context, i.e. inside the post editor or the query loop block.
  • When the button is clicked:
    • If the image source is media, it will actually update the featured image based on that media.
    • If the image source is a URL, it will download the image and upload it to media. Then it will actually update the featured image based on that media. TheIimage block's source will also be updated from URL to media.
  • The user will be notified via the snackbar when the featured image has been updated.

I need some design feedback, but I'm thinking of something like this:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Image Affects the Image Block Needs Design Feedback Needs general design feedback. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image Block: Add "make featured image" option
3 participants