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 link rel and link class to image block inspector (see #7504) #7771

Merged
merged 16 commits into from
Nov 19, 2018

Conversation

greatislander
Copy link
Contributor

@greatislander greatislander commented Jul 7, 2018

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?

  • Added link rel and link class attributes via the block inspector, saved, viewed saved post to ensure that attributes were added.
  • Added tests to fixtures.

Screenshots

Screen shot of image block inspector with link class and link rel fields added.

Types of changes

New feature: adds image link rel and class attributes to core image block.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@danielbachhuber danielbachhuber added the Needs Design Feedback Needs general design feedback. label Jul 9, 2018
@karmatosed karmatosed self-requested a review July 13, 2018 17:53
Copy link
Member

@karmatosed karmatosed left a 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?

@greatislander
Copy link
Contributor Author

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.

@karmatosed
Copy link
Member

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:

artboard

@jasmussen
Copy link
Contributor

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.

@jasmussen jasmussen removed the Needs Design Feedback Needs general design feedback. label Oct 11, 2018
@karmatosed
Copy link
Member

+1 to @jasmussen's comment to focus us on time.

@greatislander
Copy link
Contributor Author

Okay, I'll rebase.

@greatislander
Copy link
Contributor Author

Now that #6316 is merged, should the user-supplied rel be additive?

E.g. if I set my image to open a link in a new window and then add a custom rel value, should the rel be set to noreferrer noopener myrelvalue?

@getsource
Copy link
Member

getsource commented Oct 29, 2018

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.

@getsource
Copy link
Member

It's referenced above, but I pushed the updated changes to this branch:
https://github.com/WordPress/gutenberg/tree/add/image-details

I currently only have the "Open in new tab" adding to rel if rel does not have content.

getsource added a commit that referenced this pull request Oct 29, 2018
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]>
@greatislander
Copy link
Contributor Author

Rebased including a couple of tweaks from @getsource that I missed.

@greatislander
Copy link
Contributor Author

Not sure why that one test is failing ¯_(ツ)_/¯

@getsource
Copy link
Member

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
Copy link
Contributor Author

I've followed the discussion in Slack and on #7504 around this; are there still concerns about the link class and rel sidebar functionality in this PR, or is it sufficient to address those two pieces of #7504?

@getsource
Copy link
Member

@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.

@greatislander
Copy link
Contributor Author

Rebased again.

@greatislander
Copy link
Contributor Author

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!

@greatislander
Copy link
Contributor Author

@talldan @karmatosed I've updated this PR with @talldan's suggestions, rebased… any chance of another review? See also @getsource's comment: #7771 (comment)

Copy link
Member

@karmatosed karmatosed left a 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.

@greatislander
Copy link
Contributor Author

Thanks @karmatosed! Should be merge-ready once tests pass.

@greatislander
Copy link
Contributor Author

@talldan I've removed the attribute as per your comments— should be ready for another review and merge.

@greatislander
Copy link
Contributor Author

@karmatosed @talldan @jasmussen Any chance this can be milestoned for 4.5 and merged? I've resolved all review comments. Thanks!

@jasmussen jasmussen added this to the 4.5 milestone Nov 15, 2018
@jasmussen
Copy link
Contributor

Yep, sorry about that.

@talldan
Copy link
Contributor

talldan commented Nov 16, 2018

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.

@greatislander
Copy link
Contributor Author

Hi @talldan, thanks -- I will create a separate issue or PR for the linkClass issue.

@greatislander
Copy link
Contributor Author

Follow-up ticket: #11995

@designsimply designsimply added [Block] Image Affects the Image Block [Type] Enhancement A suggestion for improvement. and removed [Type] Enhancement A suggestion for improvement. labels Nov 18, 2018
@gziolo gziolo added the [Priority] High Used to indicate top priority items that need quick attention label Nov 19, 2018
rel={ rel }
>
{ image }
</a>
Copy link
Contributor

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.

Copy link
Contributor

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:

screenshot 2018-11-19 at 11 32 48

Checked out this branch and reloaded:

screenshot 2018-11-19 at 11 33 05

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:

screenshot 2018-11-19 at 11 34 52

Going back to master:

screenshot 2018-11-19 at 11 35 16

But this shouldn't be a problem unless we choose to remove this feature :D

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked again, this time I checkout master first, and set the open externally and added a custom link:

screenshot 2018-11-19 at 11 41 03

Checking out this branch and reloading still worked as expected:

screenshot 2018-11-19 at 11 41 35

👍 👍

Copy link
Contributor

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 :)

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@gziolo gziolo merged commit dfa4e04 into WordPress:master Nov 19, 2018
@greatislander greatislander deleted the add/image-details branch November 19, 2018 14:15
@StaggerLeee
Copy link

Don't forget new filter to make desired "Link to" default for all new images.

@greatislander
Copy link
Contributor Author

@StaggerLeee That should be a separate issue; I agree that functionality is needed.

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 [Priority] High Used to indicate top priority items that need quick attention
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants