-
Notifications
You must be signed in to change notification settings - Fork 4k
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 link rel and link class to image block inspector (see #7504) #7771
Conversation
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.
I would like to know if we need these all, it feels like a lot to add for image. For example do we need custom CSS when we have that on the block?
The distinction between the class on an image and the class on a link wrapping the image could certainly make a difference. I think the related issue makes a good point about maintaining existing functionality. |
As explored in #7504 I am after considering not totally sure this is a secondary settings, this should be in the actual media library itself: |
Good thoughts here. Rel is cool, especially because of the . The media library interface is a little old at this point, and deserving of love. And there's also a very strong argument to make that this feature is a link feature, not just an image link feature, and as such should be an interface that is generic to all things that can be linked. That should probably be the ultimate goal to strive towards, but in the mean time, it's probably okay to put this in the sidebar as the PR initially suggested, at least as a stepping stone towards greater things. PR needs a rebase though. |
+1 to @jasmussen's comment to focus us on time. |
Okay, I'll rebase. |
Now that #6316 is merged, should the user-supplied E.g. if I set my image to open a link in a new window and then add a custom |
Just a quick note that I've got a functioning version of this I can put in a separate branch if it's wanted. Was just figuring out how to best get it back into Github today. Edit: I'll just go ahead and put it in a branch, because it was a significant amount of changes due to Gutenberg changes in the meantime. Will comment here when it's there. |
It's referenced above, but I pushed the updated changes to this branch: I currently only have the "Open in new tab" adding to |
Merges PR #7771 to local branch to: - Bring up to date with the changes and moved files in Gutenberg - Update Tests for new expectations due to parser changes - Support rel defaults for "Open Link in New Tab" feature Props greatislander, getsource Co-authored-by: Ned Zimmerman <[email protected]>
Rebased including a couple of tweaks from @getsource that I missed. |
Not sure why that one test is failing ¯_(ツ)_/¯ |
Thanks so much @greatislander! Tested and seems to be working as expected. This was passing locally, so I went ahead and re-ran the failed travis test, and it passed. |
@greatislander I believe I just misread @karmatosed comment on #7504, based on #7771 (comment). @karmatosed, if that's the case, would you mind removing the change request? If not, we can definitely keep chatting about alternatives. |
Rebased again. |
Hi @karmatosed, can you review this again in the context of the discussion on the ticket? I think the build just needs to be restarted. Thanks! |
@talldan @karmatosed I've updated this PR with @talldan's suggestions, rebased… any chance of another review? See also @getsource's comment: #7771 (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.
Let's get this in for now, we can iterate and review the media library itself in phase 2.
Thanks @karmatosed! Should be merge-ready once tests pass. |
@talldan I've removed the attribute as per your comments— should be ready for another review and merge. |
@karmatosed @talldan @jasmussen Any chance this can be milestoned for 4.5 and merged? I've resolved all review comments. Thanks! |
Yep, sorry about that. |
Hey @greatislander - Thanks for addressing all those comments, and sorry for the delay responding. This does look good, I gave it a test and it works really nicely. I don't think the issue with the linkClass working in raw transforms was ever addressed. It'd be great if that could be created as a separate issue or PR. |
Hi @talldan, thanks -- I will create a separate issue or PR for the linkClass issue. |
Follow-up ticket: #11995 |
rel={ rel } | ||
> | ||
{ image } | ||
</a> |
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.
I wonder if this change creates an "invalid image" warning if you try to upgrade from an image with a link set to open a new tab.
- checkout master
- add an image with an external link
- save
- checkout this branch
- refresh
The image shouldn't show up as invalid. I wonder if we should add a deprecated version for this?
To clarify: I didn't have the time to test it but it's a guess.
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.
I took this for a spin, and things look like they are working as intended.
Screenshot from master:
Checked out this branch and reloaded:
I suspect the problem only occurs when you go the other way. Which is adding the attributes, then checking out a branch that removes them. And sure enough:
Going back to master:
But this shouldn't be a problem unless we choose to remove this feature :D
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.
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.
Thanks for the tests @jasmussen :)
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.
LGTM 👍
Don't forget new filter to make desired "Link to" default for all new images. |
@StaggerLeee That should be a separate issue; I agree that functionality is needed. |
Description
This is some initial work towards addressing #7504. If there's interest from maintainers, I can proceed to add the 'Open link in a new tab' checkbox and investigate automated testing of these features.
How has this been tested?
rel
and linkclass
attributes via the block inspector, saved, viewed saved post to ensure that attributes were added.Screenshots
Types of changes
New feature: adds image link
rel
andclass
attributes to core image block.Checklist: