-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[gatsby-plugin-mdx]: Double images / blurry / wrong style #15486
Comments
Also I need to set
to not overflow the image to the right (see screenshot from first comment). But that's what I had already to do before. So no change here. |
I'm seeing similar layout problems in my own site. Also using I think the problem is the inline style attribute on the Looks like some hard-coded inline styles were removed by c4a7c40. See here. I'm not sure if this was intended or not. @JoshuaWalsh @wardpeet could you chime in? Should we now be adding these styles ourselves or is something going wrong here? |
@rwieruch if you add the styles back, I think things will look they way they did before.
The problem isn't with |
Looking at c4a7c40 more carefully, it looks like This doesn't seem to be happening for me in development or production. Could the problem be a conflict with |
Yep, it's supposed to. The commit message mentions the rationale. I'm sorry to hear this isn't working for you, I will try to help find a resolution.
Possibly, I haven't used Is there a starter or public repository that reproduces the problem? |
Thank you for your help. I'll try to isolate the issue with a repo. |
I can confirm that this happens to my site when updating |
Okay, I've tracked it down. Here's a repo. I think this is a problem with My guess is that If you configure both ...
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [ `gatsby-remark-images` ],
}
},
{
resolve: 'gatsby-plugin-mdx',
options: {
gatsbyRemarkPlugins: [ `gatsby-remark-images` ],
}
}, If you don't use ...
{
resolve: `gatsby-transformer-remark`,
// options: {
// plugins: [ `gatsby-remark-images` ],
// }
},
{
resolve: 'gatsby-plugin-mdx',
options: {
gatsbyRemarkPlugins: [ `gatsby-remark-images` ],
}
}, |
@ChristopherBiscardi do you think could be related to |
I'm having this issue too but run my transformer plugins through Closed #15541 in favour of this. |
So digging a little deeper, it looks like Gatsby only looks for "subplugins" at one specific path,
If you try this… {
resolve: 'gatsby-plugin-mdx',
options: {
gatsbyRemarkPlugins: [ `gatsby-remark-images` ],
plugins: [ `gatsby-remark-images` ],
}
}, …everything works as it should. |
I am experiencing this same issue. Is the only solution to us cwgw's snippet? |
I think the solution is to ensure that @ChristopherBiscardi, am I understanding the problem correctly? Is it reasonable to just rename |
@cwgw your solution fixed the issue. |
Partially related to gatsbyjs/gatsby#15486
@cwgw Thanks for narrowing this down (and to everyone else who helped). Gatsby's handling of sub-plugins has always been special but I suppose it matters more now than it used to with the recent gatsby-remark-plugin release. The gatsby/packages/gatsby/src/bootstrap/load-plugins/index.js Lines 20 to 38 in a364c3d
gatsby-ssr functions from that earlier commit (onRenderBody ), it doesn't find it unless the plugin is also specified in plugins . gatsby-plugin-mdx technically uses the plugins array for a prototype shortcodes and components sub-plugin supply implementation in it's wrapRootElement , but gatsby-remark-images is a no-op for the files gatsby-plugin-mdx uses for that so the double-inclusion happens to work in the gatsby-config .
SO, I'm not sure what the best option is here. Adding support to The other option is to move I think something that could have a large impact on this might be to work the gatsby-remark-* plugin API surface back into compatibility with the regular remark plugins, which would also have the benefit of unifying the ecosystem again. That would make our gatsbyRemarkPlugin compat support layer unnecessary and we could entertain overlaying the remark plugin... but I haven't had a chance to work deeply on this yet, it is a big chunk of work, and will also possibly not totally solve the problem here. I wonder what @gatsbyjs/core thinks about enabling arbitrarily keyed sub-plugins (see below for pseudo-code where module.exports = {
plugins: [{
resolve: `gatsby-plugin-mdx`,
options: {
subPlugins: [`a`, `b`, `c`]
}
}]
} |
@ChristopherBiscardi thank you for the detailed explanation. And thank you for all of the work on MDX in Gatsby! You've made the point a few times that using MDX obviates the need for a bunch of the gatsby-remark plugins. I'm kind of in over my head here, but I think a fourth option would be to just drop support for gatsby-remark-* plugins. I've looked at your autolink-header and prism replacements at gatsby-mdx. It looks like they just inject components. As you envision them, do gatsby-mdx-* plugins ever touch the AST? What if gatsby-mdx-* plugins optionally exported All I really want out of gatsby-remark-images is to turn something like this
into something like this
If we could use variables in static queries then I wouldn't need a plugin. I could just write my own component around gatsby-image and import it directly in my mdx files. In lieu of that, I could do what gatsby-remark-images does, but instead of inserting hardcoded html I could insert jsx and map it to I wrote a simple plugin that does this and loaded it as a If gatsby-mdx-* plugins could touch the AST then something like this could be bundled into a nice replacement for gatsby-remark-images. |
I think this is reasonable. There wasn't any particular reason to hard-code The goal is to enable plugins to create their own sub-plugin ecosystem that works however makes sense for it while still letting these sub-plugins take advantage of Gatsby APIs. |
We can't deprecate support because that means migration for people using Also gatsby-remark-images is one of the few plugins that gatsby-mdx can not replicate without StaticQuery variables, which will come eventually but don't currently exist.
We could likely allow gatsby-mdx-* plugins to add plugins to the
cc/ @sidharthachatterjee with whom I was discussing this the other day. Should I create a new issue to track this? Seems like we have a couple options for how to do it. If we enable this, then we would also be able to enable remark-* plugins to use gatsby apis, getting us one step closer to having a solution where gatsby-remark-* plugins can be transparently used in the same place as remark plugins. |
👍 yeah let's move discussion on implementing this to a new issue |
Is this being worked on? Its an issue for queen-raae/gatsby-remark-oembed#66 as well. |
Hi. Can anyone confirm this issue is resolved? It seems my workaround is no longer required. |
@DavidSabine which workaround are you using? The what does your Gatsby configuration look like 1) before (with the workaround) and 2) now (without the workaround)? |
Hi @karlhorky, thanks for the question. My comment was cryptic I suppose. So: FIRST, note that my gatsby site inherits gatsby-remark-images from gatsby-theme-blog-core. So a couple of the 'workarounds' above (in gatsby-config.js) I've avoided. I used styles to workaround the problem.
That seemed to do the trick. On January 17th I noticed that all the images in my blog had disappeared. (https://scrum.works/articles) In fact, they had height of zero pixels (and my padding-bottom override was preventing span.gatsby-resp-image-wrapper from expanding to the height of the image. (gatsby-image-remark uses Yesterday, I removed my workaround and, voila!, images appear normally now. So, I wonder if others in this thread have observed a major change lately in the output of this plugin. |
Possibly related? #20808 |
Why was this closed @rwieruch? I don't believe this has been solved yet |
Yesterday I updated to the recent Gatsby versions and I was able to remove the workaround code. I think this is fixed. |
Hm, this seems to still be an active bug, at least when using with I still needed to duplicate the plugin also to the JaeYeopHan/gatsby-remark-images-medium-zoom#13 @rwieruch maybe consider reopening? This issue has gotten some visibility as a single point of reference for this bug, and is even referred to in some starters: |
workaround for gatsbyjs/gatsby#15486 and also this might be useful in general?
I was having this issue, and I solved by deleting "gatsby-resp-image-background-image" and "gatsby-resp-image-image" css styles that I was using. |
I am using gatsby-remark-images in my Gatsby MDX powered website. Not sure whether this was introduced during the last months, because it worked before, but after upgrading everything I have to set the following style manually to override the responsive Gatsby style to make it work in my markdown.
Otherwise I will have a large white space before my image gets rendered.
My images are used with the normal format in my markdown:
![my image alt](./images/my-image.jpg)
Dependencies:
The text was updated successfully, but these errors were encountered: