WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.47k stars 4.18k forks source link

Add option to set as feature image to image / cover block #13795

Closed spacedmonkey closed 1 year ago

spacedmonkey commented 5 years ago

When creating a post, there is a real disconnect between the content of the post and the elements in the sidebar. For this reason, I and am sure others, forget to set a featured image. Features images are useful for list pages like archives and for plugins like yoast to pick the image that best reflects the content. It feels odd that you could have a post with many images, in form of image, cover or gallery blocks and not the correct featured image.

Describe the solution you'd like Add a button to the image / cover blocks, called "set as featured image". This is just a helper that sets the current image a feature image. It could also save data on block to say it is feature. This could help themes work on the current featured image and stop it being displayed twice at the top of a post.

Describe alternatives you've considered Add a new feature image block, but this just feels like a copy of the current image / cover blocks.

draganescu commented 4 years ago

Yes, I second this idea, particularly because once I add an image, even if it is the only one i still have to add it again in the sidebar. A button to set featured image for image media blocks would be nice. I wonder if it could be something that blocks can opt into like provide featured image or something.

paaljoachim commented 4 years ago

This is a very good idea!

Perhaps something like this: Featured-image-image-blocks

Adding the Set featured image checkbox to the Image/Cover block. The image will also need to automatically be added to the Document Featured Image section.

spacedmonkey commented 4 years ago

In my head, I had a icon button in the toolbar next to the replace button.

paaljoachim commented 4 years ago

The toolbar is used for the most important features and most used icons. The sidebar are for the less used options.


EDIT:

Another example of the Image Block. I added the checkbox first and the Set featured image text after. Image-Block-Set-featured-image

Here is an example in the Cover Block. Where I have added the Featured image checkbox on the bottom right. Cover-Block-Set-featured-image


Another option I have not explored is adding it into the ellipse (3 dot menu drop down) menu for all Image and Cover Blocks. That would hide it further away though. Making it harder to discover.


NB. When a user clicks to use image as featured (Image Block or Cover Block) the image needs to automatically be inserted into the Featured image box in the Document settings.

paaljoachim commented 4 years ago

Here is another way complementary of automatically adding a featured image. Notice the checkbox and text below the Featured Image box. It adds a general way to automatically add the first image as featured. Perhaps there could be an option under document Options. So that it would be by default checked in the Options screen.

Auto-add-first-image-featured

EDIT: We could actually have "Automatically add first image as featured." checkbox pre-checked. As it would make the first image added to the document automatically added it to the "Set featured image" box. If the user forgets to add a featured image it will already be added because of the pre-checked checkbox.

If the user decides to add another image as featured then the "Automatically add first image as featured." checkbox would automatically become unchecked.

Auto-add-first-image-featured

joyously commented 4 years ago

I don't agree that adding something to the blocks is the way to do this. Perhaps just enhancing the dialog you get when you click on the sidebar Set Featured Image, to include the images already in the post. Making it part of the blocks sort of implies that they are related, when actually they are not, and the theme or plugins will do whatever they do with featured images separately from the block in the post. I can imagine that users might add an image, click your new little button, then change the image and presume that the featured image would change also. Keep the content separate from the other attributes that describe the content (taxonomies, featured image, post meta, date, visibility, etc.)

phpbits commented 4 years ago

Here's how my EditorsKit plugin is doing the "Set Image as Featured" on image block.

set-image-as-featured

draganescu commented 4 years ago

I like @joyously 's proposal to enhance the main featured image sidebar control. Adding it to blocks is also nice since it is in the context: I am already having the image that I want selected. Maybe both should be explored.

I wonder if featured image is not a variation of the image block with the featured attribute set to on.

mapk commented 4 years ago

The proposal to quickly set an existing image in the post to become the feature image is understandable. Although, I too agree that I would not want them to become tied together in a way that might confuse the user.

Keeping these separate visually and interactively also keeps them separate conceptually. Listening for more feedback sounds good here, but I'm in favor of keeping these two interactions separate for now.

paaljoachim commented 4 years ago

I would suggest adding a checkbox below the existing "Set featured image" box that says something like: "Automatically set first image as featured". Having a checkbox there it becomes associated with the existing featured image box. Keeping the feature in one place. https://github.com/WordPress/gutenberg/issues/13795#issuecomment-636787215

EDIT: It will be off by default. Leaving it up to the user to turn it on.

NB. I would suggest a code snippet to add to the functions file to automatically have the checkbox checked. http://www.indexwp.com/automatically-set-featured-image-wordpress/

mapk commented 4 years ago

That's not bad at all. It keeps the interaction tied to the featured image component. Maybe the wording can be adjusted to say... "Add the first image as featured."

cathibosco commented 4 years ago
  1. I agree keeping the interaction tied to the featured image component is optimal.
  2. I also think it should stay on the document panel as well. If it were an option in the image block it would throw errors in the editor flow process a lot of the time since an error message is often thrown when an image is not the right size for default featured images.
  3. Screen Shot on 2020-06-18 at 07-49-25
  4. This setting could be a toggle on the document panel in the featured image component but it can cause issues for users in the archive page presentation or view with duplicate images depending on the layout of their pages/posts... so, for this reason, I do not think it should be "ON' by default.

I do not understand why the editor's kit example above does not show the error unless the image in that example is already sized perfectly for the featured image...

paaljoachim commented 3 years ago

Adding some some other featured image issues as well that are associated.

Allow Post Featured Image blocks to have a consistent height https://github.com/WordPress/gutenberg/issues/27620

Rethink "Featured Image" in the context of blocks https://github.com/WordPress/gutenberg/issues/27617

Allow using featured image as background for a group block https://github.com/WordPress/gutenberg/issues/24660

altivero commented 3 years ago

Also associated:

Featured Image: Automation and improvements

31849

draganescu commented 2 years ago

I'll start exploring adding a toggle for the cover block that pulls the featured image if one is set.

draganescu commented 2 years ago

Looking into this, considering the advancements we have had from the work on entities, it seems @jasmussen has a great point in solving this via the media replace flow component. It would automatically make the featured image available as a source for many blocks and it's also pretty intuitive as a workflow.

jasmussen commented 2 years ago

We could also maybe start with it as part of the replace flow and then the URL can be tokenized later if it makes sense?

draganescu commented 2 years ago

Some questions I stumbled upon while researching this:

jasmussen commented 2 years ago

CC: @dmsnell as I think you've been looking into some token stuff.

dmsnell commented 2 years ago

Thanks @jasmussen. While we don't have working code to my knowledge, the idea in proposal is that we can create a special URL or token of some kind that indicates the source of an image is "the featured image" of the post in context (could be on a page itself, could be the current post in a query loop).

This is opposite of my understanding of this PR, which is to instead say, "set the post's 'featured image' to be this particular image." This is conceptually much simpler.

jasmussen commented 2 years ago

This is opposite of my understanding of this PR, which is to instead say, "set the post's 'featured image' to be this particular image." This is conceptually much simpler.

If this is simpler, would you mind if this one landed as a small improvement without the need for tokens?

I know I mentioned it initially, but after mulling it over, I have a feeling that tokens in URLs might make for a somewhat tricky UI, and that tokens for example in a date block might be more intuitive as a starting point:

[Postname] was published on [Date] and filed in [Category]

What do you think?

paaljoachim commented 2 years ago

A thought.... Could we when adding the first image to the canvas automatically have it added as a featured image? Seen in the featured image box. This way a user would notice that the first image has been already set in the featured image box, and if they want to use another image they will replace the "default" featured image. As it can many times be easy to forget to set a featured image for a post or find it cumbersome to always manually have to add one.

joyously commented 2 years ago

[Postname] was published on [Date] and filed in [Category]

Cool! Going back to shortcodes? This really underscores the need to keep the content separate from the extra stuff that describes it, like taxonomies and featured image. I don't think the featured image should be shown in the editor's content area, since the theme or plugin (even blocks) can do lots of different things with it dynamically.

jasmussen commented 2 years ago

Not so much shortcodes, as you wouldn't write them, you'd pick them from a list. I can't find the issue right now, but something like this:

Meta chips
dmsnell commented 2 years ago

If this is simpler, would you mind if this one landed as a small improvement without the need for tokens?

Not at all, if my understanding is correct. Specifically, that this feature request has nothing at all to do with tokens or indicating that when rendering, a given image should show the featured image for a post.

In my understanding this feature request is specific to the image and cover blocks and amounts to a shortcut function: "go ahead and set this one as the featured image for the post."

Could we when adding the first image to the canvas automatically have it added as a featured image?

Just my own two cents here: that seems like a double-edged sword since I think I've seen plugins and themes that use their own methods to pick a featured image (when none is already set). Maybe it's a good idea to force-choose a featured image 🤷‍♂️ - probably worth a different issue.

Also worth a different issue, while we're discussing it, is why not present a drop-down on the featured-image selector that not only lets you upload or pick an item from the media library, but shows a small thumbnail grid of all the images currently in the post. That could get the featured image picking closer to the task at hand. It would work well with a shortcut from the image block.

❓ How hard would it be to realize this feature request as an extension that we can apply to the block vs. hard-coding the behavior inside the block? Could we write out the behavior as a hook and inject the button into the block's inspector or toolbar?

paaljoachim commented 2 years ago

As @draganescu made the PR for "Makes cover block dynamic and adds featured image binding" and went ahead and closed this issue. Is there something we should move over to a new issue that has not been dealt with here?

There is also this issue: Fallback Featured Image https://github.com/WordPress/gutenberg/issues/32447 Which I believe is associated.

Both issues are closed but fallback featured image has not been dealt with yet, so that should be reopened. (Commenting there as well.)

paaljoachim commented 2 years ago

We now have an icon in the Cover block which we can click to add the Cover block image as a featured image.

Screenshot 2022-05-08 at 13 08 28

We do not yet have this new feature (icon) added to the Image block. Screenshot 2022-05-08 at 13 09 32

@draganescu Andrei. Let's get the same feature added to the Image block. I will reopen this issue as one part is done but the other part (Image block) has not been done yet.

Regarding Featured images. Check out this article at WP Tavern: https://wptavern.com/wordpress-should-support-featured-images-for-categories-users-and-more

noisysocks commented 2 years ago

Un-assigning @draganescu as I think this issue is waiting for someone to pick it up.

jordesign commented 1 year ago

Just checking if we still need this given it is possible to insert a 'Featured Image' block?

jasmussen commented 1 year ago

I don't know that it needs a separate issue, but there are some things we need to explore in 6.4 around connecting refrences. For starters it will mainly be colors (I want to use the text color for my background, and the background color for my text), but images may be a part of that as well. It needs a generic solution that would also work for plugin blocks, and media and text.

draganescu commented 1 year ago

@jasmussen what exactly is left for this issue to be closed? #41704 seems to point to not wanting featured prop of image block. What else?

jasmussen commented 1 year ago

I'm actually happy to close this issue, simply because its use case will likely be addressed by the ref/token system, and with 5000+ issues it's only good to consolidate!