Closed mertcangokgoz closed 2 years ago
Hi! Does this happen to every image file in your posts? Are you running the latest version of gem or a version in _plugins
folder?
Hi @juusaw
I am having a similar problem. When it compiles I get this error:
Unable to get image dimensions for "/Users/chris/html/guide/_site/guide/images/blog-images/fort-myers.jpg". For local files, build the site with '--skip-initial-build' for better results. [Error: undefined method `[]' for nil:NilClass]
The URL for the images is correct on the page, the images are saved here and work for the non amp pages: "/Users/chris/html/guide/images/blog-images/fort-myers.jpg"
When it is compiling it's added an extra '/guide/_site' into the URL, this is why it cannot find the files. I do not use a '_site' folder. I have changed it in my config like this:
baseurl: "/guide"
I installed the gem by including it inside the gem/config files and running bundle.
Can you help me please?
Thanks Chris
Hi @juusaw
I see the following error in the post with each photo. Sometimes it does not give an error.
Unable to get image dimensions for "/home/mertcan/Desktop/mertcangokgoz.github.io/_site/assets/telegramprotokolgorsel_vl0gf9.jpg". For local files, build the site with '--skip-initial-build' for better results. [Error: undefined method `[]' for nil:NilClass]
Jekyll Build Output
https://travis-ci.org/MertcanGokgoz/mertcangokgoz.github.io/builds/247684294
This does affect amp in that it leaves out the height/width attributes of images, making them invalid.
The error occurs when build
ing the first time. If you build twice, leaving in original _site
folder after the first time, the second time will work without errors.
I have observed this error happening to all the images which have a class mentioned in markdown. Something like this
[Alt text](/path/to/image.img){: .full}
But once I remove{: .full}
, no error is seen.
I hope something with the amp_images filter is wrong. It may not be able to properly read images with markdown class attribute.
@moonshark looks like you have changed the destination in _config.yml. When I changed it, I got a lot of errors. All of them were [Error: undefined method
[]' for nil:NilClass]`.
Then I found the particular ruby gem, changed the code a little bit and then it worked as expected.
Usual location of the gem is C:\Ruby22\lib\ruby\gems\2.2.0\gems\amp-jekyll-1.0.2\lib\jekyll
. It depends on where you have installed it.
Find the gem and change the below line (line no. 24) from
src = File.join(Dir.pwd, '_site', image['src'])
to
src = File.join(Dir.pwd, '', image['src'])
That should work.
I had this issue happen on every build when cloning a Jekyll site git repository and using jekyll build --source [path] --destination [path]
. Since I was using source / destination, the _site_
folder was not getting created in the source path so even sequential builds were failing. My final solution was to symlink _site_
to the source root so it would be able to find the images: https://github.com/bradymholt/geekytidbits.com/blob/master/ansible/roles/git-bare/templates/post-receive.j2#L11. I do think https://github.com/juusaw/amp-jekyll/blob/f077aa422245f49ee49a60efdb3889fda287c77d/lib/jekyll/amp_filter.rb#L24 needs to be changed to:
src = File.join(Dir.pwd, '', image['src'])
How to fix this, not generate _site folder
And modify amp.html because im not using any header or footer html