Closed bryanbergman closed 10 years ago
Can you post your picture
settings from _config.yml?
Line 42 deals with getting the preset settings from config.yml. Last time I saw this error someone was missing the required default
preset, so that's a possibility.
picture:
source: post_img
output: generated
markup: "picturefill"
presets:
default:
attr:
class: "post-img"
source_default:
width: "360"
height: "771"
source_720:
width: "720"
media: "(min-device-pixel-ratio: 1.5)"
source_430:
width: "430"
media: "(min-width: 360px)"
source_860:
width: "860"
media: "(min-width: 360px) and (min-device-pixel-ratio: 1.5)"
source_500:
width: "500"
media: "(min-width: 430px)"
source_1000:
width: "1000"
media: "(min-width: 430px) and (min-device-pixel-ratio: 1.5)"
source_640:
width: "640"
media: "(min-width: 500px)"
source_1280:
width: "1280"
media: "(min-width: 500px) and (min-device-pixel-ratio: 1.5)"
articleimg:
attr:
class: "post-img"
source_1200:
width: "1200"
media: "(min-width: 940px)"
source_940:
width: "940"
media: "(min-width: 780px)"
source_780:
width: "780"
media: "(min-width: 600px)"
source_600:
width: "600"
media: "(min-width: 470px)"
source_470:
width: "470"
media: "(min-width: 360px)"
source_default:
width: "360"
It looks like you're right. There's an issue with the context variable used to render liquid inside the tag when the tag is used in a layout — it's either not getting picked up properly or doesn't exist. I'll take a look into this, see what I can find.
I'm getting this same error. Have a solution been found?
This would be something to ask about in the Jekyll queue. Last time I checked, context just wasn't available in layouts the same way as in posts.
So if I put the {% picture %} tag in the post rather than the layout, it should work?
It sure should.
Rob Wierzbowski @robwierzbowski http://twitter.com/#!/robwierzbowski http://github.com/robwierzbowski http://robwierzbowski.com
On Fri, Feb 28, 2014 at 4:22 PM, PatrickC8t notifications@github.comwrote:
So if I put the {% picture %} tag in the post rather than the layout, it should work?
Reply to this email directly or view it on GitHubhttps://github.com/robwierzbowski/jekyll-picture-tag/issues/11#issuecomment-36395724 .
I think I've gotten around the issue by using https://github.com/rustygeldmacher/jekyll-contentblocks
I have the same issue, cant really use any of the presets, it keeps falling back to the default.
For now, contentblocks is the preferred fix.
After installing the gem, I got undefined method '[]' for nil:NilClass
error when compiling. Defining the default
preset in _config.yml
solved this.
Adding a more informative exception message ("Default preset configuration not defined") would be beneficial to new users.
I can confirm that @anroots suggestion worked for me to. Though I have another issue know, not sure if it's related…
When I try to run Jekyll, I get
Liquid Exception: undefined method
[]' for nil:NilClass in post.html`A traceback shows
/Users/Bryan/Desktop/sl/_plugins/picture_tag.rb:42:in
render': undefined method[]' for nil:NilClass (NoMethodError)
post.html is in my _layouts, I wonder if that is affecting it.
``html {% include header.html %}
{% include footer.html %}