rgpages / rgpages.github.io

This page was created and is cared for by The Register-Guard web team to curate special online presentations of static stories. Additionally, it houses open-source story templates.
http://pages.registerguard.com/
0 stars 0 forks source link

update image #3

Closed robertdenton closed 10 years ago

robertdenton commented 10 years ago

So I can put this in my _config.yml per Jekyll configuration docs...

defaults:
  -
    scope:
      path: ""
    values:
      postimage: "default.png"

AND I can set postimage in head matter like so..

postimage:      "default.gif"

BUT it only pulls the head matter postimage not the default.

Solution:

There isn't one. Github is on Jekyll 1.5 and Jekyll 2 and up supports defaults. So I did this as a fix:

{% if post.postimage %}
  <img src="http://pages.registerguard.com/{{ post.slug }}/{{ post.postimage }}" width="100%" style="border:1px solid black">
{% else %}
  <img src="http://pages.registerguard.com/{{ post.slug }}/default.png" width="100%" style="border:1px solid black">
{% endif %}