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

Add a link section for Cover Image Block Settings #12684

Open
CalumChilds opened this issue Dec 7, 2018 · 77 comments
Open

Add a link section for Cover Image Block Settings #12684

CalumChilds opened this issue Dec 7, 2018 · 77 comments
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Feature] Media Anything that impacts the experience of managing media Needs Accessibility Feedback Need input from accessibility [Type] Enhancement A suggestion for improvement.

Comments

@CalumChilds
Copy link

CalumChilds commented Dec 7, 2018

Is your feature request related to a problem? Please describe.
I want to link a cover image block to a particular page, which I can't do without delving into the code.

Describe the solution you'd like
A "Link" section in the Block settings sidebar (see below)
image

Describe alternatives you've considered
For now, I will use HTML to link it to the page I want. But most people using this new editor have probably never heard of HTML, let alone coded in it.
(Edit: I've just tried to do this and it says that the block contains "unexpected content" - see below:)
image
This is the code I entered:
image

@designsimply designsimply added [Type] Enhancement A suggestion for improvement. [Block] Cover Affects the Cover Block - used to display content laid over a background image labels Dec 7, 2018
@jaclyntan
Copy link

Along with link options I'd also like to add headings and paragraphs within the block.
I know a section block was being explored but I'd like to see more options in the cover block so it's more flexible. Thank you!

@CalumChilds
Copy link
Author

@jaclyntan This has been done in Gutenberg 5.3, where you can now add blocks within the Cover Block.

@foosantos
Copy link
Member

@affeldt28
Copy link

I would like to see the feature implemented, its a bit annoying to always manually edit as html and add links.
Sad that since 2018 nobody done it. i think it shouldn't be very difficult to do.

@boomtemp123
Copy link

Same here, being able to link these is a good idea and something that you'd expect to be one of the basic functions. Kioken blocks allows this on it's image block.

@boomtemp123
Copy link

@phpbits
Copy link
Contributor

phpbits commented Feb 10, 2020

Added Link toolbar to EditorsKit plugin for the following blocks. I hope this could be of huge help. Thanks!

  • Cover Block
  • Group Block
  • Column Block

Options available are:

  • Link to New Tab
  • NoFollow rel attribute
  • Sponsored rel attribute
  • Hover animation option

Here's the preview and EditorsKit is available for free on the plugin directory.

Add a link section for Cover Image Block Settings

@paaljoachim paaljoachim added the Needs Dev Ready for, and needs developer efforts label Jun 2, 2020
@paaljoachim
Copy link
Contributor

We need a developer to add this into the Cover Block similar to how Media & Text Block now has a link.

Media & Text Block has in the toolbar a link icon to the left of the Replace button.
Screen Shot 2020-06-02 at 17 28 16

For the Cover Block one would do something similar. Adding a link to the left of Replace button.
Like this mockup:
Cover-Block-Link-wireframe

@CalumChilds
Copy link
Author

CalumChilds commented Jun 2, 2020 via email

@tripledm
Copy link

tripledm commented Jun 2, 2020

As mentioned earlier in this thread, there is already a plugin (EditorsKit) with this feature embedded. We have a working prototype, all someone needs to do is add it to the Gutenberg code.

Sadly EditorsKit works on one site but the others I manage not as just getting a blank screen and timeout when I try edit a post during tests. Anyway, not the forum for that topic as it's a conflict somewhere but to bump your request up with my response.

The issue was raised (this thread) 1.5 years ago and considering the importance of this I would only hope it's added to core sooner rather than later.

@paaljoachim paaljoachim added the Good First Issue An issue that's suitable for someone looking to contribute for the first time label Jun 30, 2020
@kjellr
Copy link
Contributor

kjellr commented Aug 17, 2020

Just want to add my voice here to say that the native ability to link an entire Group or Cover block to a single URL would definitely come in handy for a variety of layouts.

Here's an example pattern that features two "Cards". Ideally, these entire cards would be clickable, but there's no way in Gutenberg today to make that happen.

Screen Shot 2020-08-17 at 1 00 08 PM

(design via @beafialho)

@CalumChilds
Copy link
Author

CalumChilds commented Aug 17, 2020 via email

@enriquesanchez enriquesanchez added the Needs Accessibility Feedback Need input from accessibility label Sep 10, 2020
@cguntur
Copy link

cguntur commented Sep 23, 2020

I can take up this one.

@ZebulanStanphill
Copy link
Member

I know links can often eat semantics when used improperly, so I think we ought to be careful about adding something like this. It's possible that this may be an accessibility anti-pattern that we should avoid at all costs... or it could be completely fine. I'm not really sure. Pinging @afercia from the accessibility team to check this out and give feedback.

@afercia
Copy link
Contributor

afercia commented Sep 24, 2020

Cover blocks (and group blocks, and possibly other blocks) can already contain links:

Screenshot 2020-09-24 at 10 22 12

When a "block-level link" is added to wrap the block, there shouldn't be other links within the block content to avoid nested links. So this feature should make sure to:

  • automatically remove links within the content, if any
  • remove from the UI of any block within the cover/group the ability do add links into the content

@afercia
Copy link
Contributor

afercia commented Sep 24, 2020

I know links can often eat semantics when used improperly,

Yep, it really depends on what's inside the linked block. Expanding my previous comment: what if inside the block there's, say, an input field, or a button, or any other interactive element? A link should contain only non-interactive elements. The implementation should make sure to avoid nested interactive elements. At a first glance, this appears to be a bit complicated especially with existing content: should the block content be "cleared" of any interactive element when the block gets linked?

@CalumChilds
Copy link
Author

CalumChilds commented Sep 24, 2020 via email

@afercia
Copy link
Contributor

afercia commented Sep 24, 2020

I don't think anyone putting a link around the Cover block would be having any input fields or buttons inside it,

I don't think we can trust users this way 🙂 Valid, semantic, accessible markup should be enforced via code.

@ZebulanStanphill
Copy link
Member

The disable-link-control-on-nested blocks idea sounds very similar to the issue where sometimes we want to disable the block alignment controls for blocks when they are nested inside another block with a layout/style that doesn't support those alignments. Perhaps the solution to both problems is the same... but I'm not sure what that solution is.

@cguntur
Copy link

cguntur commented Sep 28, 2020

I might need some guidance on this one.

@paaljoachim
Copy link
Contributor

Hi Chandrika @cguntur

After you get a bit going you can then ask questions that arise directly in the core-editor Slack channel, and let people know that are you are new and working on figuring out ......
You can also ask questions during the Open Floor of a core editor chat.
There are many people that can give help.

@cguntur
Copy link

cguntur commented Sep 29, 2020

@paaljoachim Ok, I will give it a try. Thank you for the help.

@talldan
Copy link
Contributor

talldan commented Sep 30, 2020

Not that I disagree with the intent of preventing invalid markup, but this feature sounds like a bit of a minefield in terms of implementation.

Any feature would have to handle various situations:

  • Links already exist on inner blocks when the user wants to apply the cover block link (is the cover block link interface disabled in this situation? Or alternatively inner block links are stripped when the cover links is applied? What about blocks that represent entire links (e.g. buttons), how are they handled? Third-party blocks?)
  • The user applies the outer link and then tries to add inner links (is the inner block link interface disabled in this situation? And then what about button blocks and third party blocks?)
  • Detection of inner links would have to work for any level of block nesting.

I also think it's going to be hard to relay to the user what the problem is that's preventing the addition of links.

Feels like this particular problem needs some design input more than anything, so I'll apply that label.

@passatgt
Copy link

Want to add a CSS solution until this feature is available. Add the class-name "full-link" to your cover image block under the advanced tab:

image

Add a link to any of the content inside the cover image. This can be an empty paragraph with a space too for example, you just need a link inside the block. Then add the following extra CSS under Styles / ... / Additional CSS:

image
.full-link a:after {
display:block;
position:absolute;
left:0;
top:0;
width:100%;
height:100%;
content:'';
}

Now your click area is expanded to the whole block. Class can be used on any other block too.

@tnchuntic
Copy link

Any updates on this "add link functionality to Cover block"?

@AceMedia
Copy link

AceMedia commented Sep 8, 2023

I'd love to see this implemented.

@passatgt
Copy link

passatgt commented Sep 8, 2023

Another solution is to create an extra style for the cover block. Add this code to your functions.php:

add_action( 'init', function(){
    register_block_style( 'core/cover', array(
        'name'         => 'full-link',
        'label'        => 'Link',
        'inline_style' => '.wp-block-cover.is-style-full-link a:after {
            display:block;
            position:absolute;
            left:0;
            top:0;
            width:100%;
            height:100%;
            content:"";
        }'
    ));
});

This will create a new style for the cover image block called Link, and you can select it in the styles tab:

image

And after this, it works the same way as my css solution above, just add a link inside the cover image to any element and it will make the whole block clickable.

@ACAwebbuilder
Copy link

ACAwebbuilder commented Sep 17, 2023

Hi passatgt!

Thanks for this idea. I just tried it and don't have the Styles section set-up like in your image. I pasted the code in my Child theme's Function.php.

It is my first time editing that file...is there a specific place I am supposed to paste?

@passatgt
Copy link

Hi passatgt!

Thanks for this idea. I just tried it and don't have the Styles section set-up like in your image. I pasted the code in my Child theme's Function.php.

It is my first time editing that file...is there a specific place I am supposed to paste?

Might be a theme compatibility issue? I tried it with the default twentytwenty-three theme and works fine in the functions.php.

@davipontesblog
Copy link

Similar request from WordPress.com customers as well.

@Gustavo-Hilario
Copy link

+1

1 similar comment
@masperber
Copy link

+1

@dolgelukkig
Copy link

  • 1

@chekle
Copy link

chekle commented Mar 14, 2024

+1

1 similar comment
@gregdotelphotography
Copy link

+1

@DeanE1
Copy link

DeanE1 commented Mar 26, 2024

How has this not been implemented into core yet? I thought I had this problem licked adding an image with a text overlay just to find it converts my block to a cover image which does not allow the image to be clickable. Please add this seemingly basic function to core.

@smetsson
Copy link

smetsson commented Apr 5, 2024

  • 1 👍

@iamtakashi
Copy link

+1. It has been said before, but the cover block is useful in a query loop to show featured images with titles etc. It's a very common pattern for the thumbnail(featured image) to be clickable.

@beeceemato
Copy link

+1. This is a very essential missing feature.

@mateitudor
Copy link

It's been 84 years

@akasunil
Copy link
Member

Another solution is to create an extra style for the cover block.

We can do this by creating a layer with a link that overrides the cover block. As the link layer will be on top of everything, other links wont be clickable. It is tricky to prohibit inner blocks from having links. We should consider an alternative approach given this is an essential feature that would benefit many users.

@mateitudor
Copy link

A solution I think is good is to surface that information to the user: "hey if you want the whole column / cover to have a link then all the links inside it will be turned into plain text".

I don't think it's okay to have bad markup and just prohibit default behavior from javaScript. It should be pre-rendered correctly by default.

As long as the user knows what is happening it should make for good UX and the end result is valid markup :)

@uniquesolution
Copy link

Wordpress core team please consider the solution I am suggesting here #45959 (comment) , this way we will have a accessible, easy to implement link to whole card layout created with group block.

@djpane
Copy link

djpane commented Aug 28, 2024

@passatgt A pretty clever solution!
@ACAwebbuilder It's been a while from your issues. If you change the first line of the css from .full-link a:after { to .is-style-full-link a:after { it should work.

@gOuTM
Copy link

gOuTM commented Sep 2, 2024

Dears.
The solution used by many wordpress-site users is down since the wordpress update 6.6 and it is not clear whether it will be fixed or not (https://wordpress.org/support/plugin/block-options/). That's true that plugin support is responsibility of a plugin owner.

But still, the requested feature is essential for a lot of people here. The solution, provided by the plugin, might be not ideal. but it worked. I read the discussion, that as for that time core team did not see a clear solution for that, but I believe that it can be arranged.

So, could somebody from the core team look into this please?

@gOuTM
Copy link

gOuTM commented Oct 28, 2024

Dear @passatgt , is there any chance to have similar functions.php -based solution for column block? (or maybe even group block?) Thanks!

@passatgt
Copy link

Dear @passatgt , is there any chance to have similar functions.php -based solution for column block? (or maybe even group block?) Thanks!

You can register the same hook for multiple blocks, should work:

add_action( 'init', function(){
    register_block_style( 'core/group', array(
        'name'         => 'full-link',
        'label'        => 'Link',
        'inline_style' => '.wp-block-group.is-style-full-link a:after {
            display:block;
            position:absolute;
            inset:0;
            content:"";
        }'
    ));

	register_block_style( 'core/column', array(
        'name'         => 'full-link',
        'label'        => 'Link',
        'inline_style' => '
			wp-block-column.is-style-full-link {
				position:relative;
			}
			.wp-block-column.is-style-full-link a:after {
				display:block;
				position:absolute;
				inset:0;
				content:"";
        	}
		'
    ));
});

@khristiansnyder
Copy link

  • 1 to get this added. #8968161-zen-a8c

@Marc-pi
Copy link

Marc-pi commented Nov 5, 2024

+1 yep, a very strong need indeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Feature] Media Anything that impacts the experience of managing media Needs Accessibility Feedback Need input from accessibility [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests