-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
feat(mdx-loader): read image dimensions when processing Markdown #6339
Conversation
✔️ [V2] 🔨 Explore the source changes: 884a466 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/61e261d4a651c300088e07b1 😎 Browse the preview: https://deploy-preview-6339--docusaurus-2.netlify.app |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-6339--docusaurus-2.netlify.app/ |
Size Change: -25 B (0%) Total Size: 677 kB ℹ️ View Unchanged
|
@@ -181,6 +181,3 @@ html[data-theme='dark'] img[src$='#gh-light-mode-only'] { | |||
.test-marker-site-custom-css-unique-rule { | |||
content: "site-custom-css-unique-rule"; | |||
} | |||
.test-marker-site-custom-css-shared-rule { | |||
max-width: 100%; | |||
} |
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.
This test is removed. We can't guarantee what this rule will be merged into because other bundled CSS may change. We can only guarantee site CSS is inserted after client module CSS.
Thanks 👍 I couldn't repro the issue on the prod blog post 🤷♂️ but still LGTM 👍 |
You probably have to both clear the cache and turn on Network throttling... Took me a while to reproduce. |
already tried that, didn't work, same effect on both links |
Hi! I've been following this issue for some time. I'm very grateful for the "Read image dimensions when processing Markdown" fix. But it doesn't seem to work completely for me. After updating to the latest version (2.0.0-beta.15), I still have some problems landing on the appropriate header on a page with various images. For example, if I put the URL directly in the web browser, the page opens up in the exact place. Here is an example:URL (works perfectly): Below is a blog page within my documentation with the above link in the form of a button. Pressing it will leave me above the indicated header (cache must be cleared or working in incognito mode): Just in case, here is the repository the documentation is hosted in: THANK YOU! |
@Mauriceac this is because you are not using markdown images: <img
alt="edit workflow group"
className="img_sizing item shadow--tl"
src={useBaseUrl("img/admin_workflowgroup_edit_00a.png")}
/> We can't easily automatically apply width/height to those images declared through JSX., particularly when the string can be provided in fancy JS ways such as: <img
alt="edit workflow group"
className="img_sizing item shadow--tl"
src={useBaseUrl("my-image-folder/" + imageIndex(3))}
/> We'll try to provide an official Image component later: <Img
alt="edit workflow group"
className="img_sizing item shadow--tl"
src="img/admin_workflowgroup_edit_00a.png"
/> Until then, if you want width/height to be applied, there's no other choice than using md images unfortunately. You can try to write your own webpack loader that gives you the size of the image so that you can write something like import myImage from "@site/static/img/admin_workflowgroup_edit_00a.png";
<img
alt="edit workflow group"
className="img_sizing item shadow--tl"
src={myImage.url}
width={myImage.width}
height={myImage.height}
/>; |
@slorber Thank you very much for such a quick response and solution! |
Motivation
Fix #3081. If we read the image's dimensions and ensure that the generated DOM has the aspect ratio, the browser can leave enough whitespace.
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Get an incognito to bypass cache. Visit these two URLs: