-
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-remark-images not showing certain images in build
#2440
Comments
I have the same issue, when I'm in gatsby develop it displayed the images correctly but on build the images can't be found. |
Upon investigation, I think my problem occurs because of the prefix path |
@markanthonyuy yeah we seemed to have lost the code adding
|
@KyleAMathews @dougajmcdonald @markanthonyuy did you find any workaround ? |
I was having this same issue. {
resolve: 'gatsby-transformer-remark',
options: {
plugins: [
{
resolve: 'gatsby-remark-images',
options: {
maxWidth: 690,
pathPrefix: '/blog',
}, // etc. etc. and it seems to be working fine in production but not in dev. |
@HyperSprite gatsby-remark-images doesn't have a |
You perhaps just need to build your site with |
Sorry about any confusion I may have added to this thread. |
@HyperSprite I am still having the same issue in production. It seems my images are still trying to link to |
@zamhaq I'm no expert but what I've done to get mine to work reliably is clear the cache and follow the rest of the docs. There may be better solutions out there but this is working for me. In my module.exports = {
pathPrefix: '/blog',
// plus all the rest of the config Then I have two custom npm run scripts in my package.json that clears the cache before running the that mode.
scripts: {
"dev": "rm -rf .cache/* && gatsby develop",
"deploy-pl": "rm -rf .cache/* && gatsby build --prefix-paths
} Then run
|
@HyperSprite Thanks. So we need to clear the cache each time? I'll try this out. |
@HyperSprite @KyleAMathews When I open index.html from the public folder in the browser I see my navigation element but not the images. However I can see the img tag in the dev tool and changing its src from Everything works okay without the above issues when I load the site to localhost via |
I just had the same issue with all my svg's; I'll help look into this next week. Looks like it might be that png's are fine and this issue's only appearing with They get copied onto the target but somewhere along the lines the pathPrefix is missing. I'm guessing it starts somewhere around here: https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-remark-images/src/index.js#L138-L141 |
It looks like any data that gets cached needs to be destroyed when going between prefixed and non-prefixed builds. I only see this when switching between the different build types. Maybe we could just set a file flag in cache? If it says development, and you run development, no issue. If it says production and file flag says development, wipe public, wipe cache, start fresh. Could do the same for dev, prod, prod + prefix. |
Yeah — the remark caching doesn't account for prefixed & non-prefixed builds. Would love a PR adding if pathPrefixing is enabled to the cache keys!
|
Could this issue be related to what I am currently seeing, which is when I have a .gif and .png image in a markdown file, the gif renders, but the png never even ha the HTML for it rendered? |
@Aaronm14 Did you ever figure this out? I'm having the opposite issue. pngs are working but gifs are not. |
@alisonjoseph - Wish I had a better answer for you here because this was driving me crazy. My buddy was saying it was working for him and I just let him upload the rest of the content, never quite figured out what it was :(. I think it was just one of those weird things, nothing I or he did specifically to make it work I don't think. Maybe it was like a minor package version difference we had from running npm install at various points |
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub issues, we have to clean some of the old issues as many of them have already been resolved with the latest updates. Please make sure to update to the latest Gatsby version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 |
This issue is being closed because there hasn't been any activity for at least 30 days. Feel free to open a new one if you still experience this problem 👍 |
I've recently added
gatsby-remark-images
to my site and have two markdown posts with images. Both images are referenced in their respective.md
files like so
In both cases I have the following file structureIn
gatsby develop
, both images show correctly in the posts and when I rungatsby build
locally, I can see both images output to the public folder in the many sizesgatsby-remark-images
generates.However, when I run my build on
wercker
only one of the posts generates the HTML to render the image.I'm just about to check the output files in the production to see if the production build actually produced the image files for the missing post, but wondered if there is any way I can begin to debug this apart from checking the output and fiddling with versions etc.
EDIT:
Having checked my production server, only the images for one of the two posts have even been generated so I'm now wondered why? Is there anything in
gatsby-remark-images
which would stop it trying to generate images under certain conditions? (Do the image have to be any specific size to start with? is there any dependency between the image size and the config options in the plugin etc?)I couldn't find too much in the docs in this area,
If it's any help, my config is as simple as I could make it.
The text was updated successfully, but these errors were encountered: