-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Only show rich preview for image and description if data is available #33660
Only show rich preview for image and description if data is available #33660
Conversation
…able If we don't do this then we might see the placeholders for desc and image just because we have a icon.
Size Change: +1.86 kB (0%) Total Size: 1.08 MB
ℹ️ View Unchanged
|
This is very nice! I detected this problem in sites that only have a meta description (in this case the favicon also failed to appear): This also happens in https://eldiario.es, for example. |
Nice catch. I've fixed this by removing the 100px min height (see video below).
@javierarce Not sure what you are seeing but I suspect it's actually the delayed loading of the icon from the remote site that is the issue. In the example you provided the rich data does in fact contain an {
"title": "elDiario.es - Noticias de actualidad - Periodismo a pesar de todo",
"icon": "https://eldiario.es/favicon.png",
"description": "Diario digital de noticias de actualidad sobre política y economía, análisis y blogs de opinión. Dirigido por Ignacio Escolar. Periodismo riguroso, independiente y honesto.",
"image": ""
} The link preview renders the img tag which links to the icon in rich data. The browser then initiates a HTTP request for the icon which takes unknown amount of time to resolve. Eventually the image data is returned to the browser and image is painted to the page. Here's a demo Screen.Capture.on.2021-07-29.at.12-39-01.mp4I think what you are seeing/experiencing is the delay in the image being requested from the remote site which is unfortunately outside of our control. I checked the logic again and the favicon will render regardless of whether description or image are available. |
Perfect, this works great now.
It was… my ad blocker, sorry 🤦♂️ The problem with the missing favicon only happened with the Verso site, that's why I thought it had to do with their meta tags. |
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.
Looks good to me ✨
Description
The Link UI's rich preview feature for remote URLs was showing placeholders for image and description even thought that data did not exist in the rich preview data.
This would allow you to arrive at states such as:
This PR corrects that by only showing the lower half of the rich preview if the necessary data is available. It will also only show the description or image if they are available.
@javierarce I think this was actually an intentional feature. I know that because we encoded the feature into the tests!
gutenberg/packages/block-editor/src/components/link-control/test/index.js
Lines 1960 to 1961 in 40a511e
Therefore I'm checking in with you to make sure you're aware that this change is being made. Essentially if the content doesn't exist then we won't see a placeholder.
How has this been tested?
Note we have quite a bit of test coverage here so it should 🤞 🤞 🤞 🤞 be safe.
Screenshots
Types of changes
Checklist:
*.native.js
files for terms that need renaming or removal).