Closed semireg closed 10 years ago
Solution to question number 1 -- just pipe it to the image command.
{% assign badge_url = page_url | append: '/' | append: page_url | append: 'png' %}
{% badge_url | image %}
Solution to number 2 -- I used what amounts to a front-matter BOOL to control whether or not the image is loaded.
Heya,
I'm glad that you found solution. Solution (1) is absolutely legit. All liquid tags provided by jekyll assets are also available as liquid filters. Solution (2) is not available out of the box. But if it's very important/interesting it's possible to add {% asset_exist? %}
liquid tag.
Here's another solution from Jekyll docs - http://jekyllrb.com/docs/templates/
ProTip™: Use variables as file name The name of the file you wish to embed can be literal (as in the example above), or you can use a variable, using liquid-like variable syntax as in {% include {{my_variable}} %}. Note that unlike usual liquid variable syntax, you cannot have spaces inside the curly braces.
Sorry to reopen this, but any thoughts on this issue:
{% assign post_image = post.image_thumbnail_500x500 | 500x500.gif %}
{% image {{post_image}} %}
No matter what I try, it will not access the variable?
Sorry to reply with such a delay. But I didn't mentioned your last comment. The issue is pretty common in liquid:
Liquid does not interpolates liquid inside liquid
So instead of {% image {{some_var}} %}
you have to use filter helper: {{ some_var | image }}
.
Although I'm not sure what you mean with:
{% assign post_image = post.image_thumbnail_500x500 | 500x500.gif %}
Np, thanks man.
@ixti Tried the approaches described above, but I'm hitting this (old and oddly familiar) issue: https://github.com/jekyll-assets/jekyll-assets/issues/121#issuecomment-95358660
Any help appreciated.
Phillip.
Hmmm... actually {{ 'file_name' | asset_path }}
works (no variable, using single quotes around the file name), but {{ file_name | asset_path }}
does not (where file_name is an assigned variable).
Thoughts on this?
@phillipadsmith sorry, I am not much help on this, will have to defer to others. I moved to Middleman.
@ixti Actually, I figured it out. Never mind. Bad quoting on my part. :(
Is there any way to pass a variable to an asset command?
Also, is there a way for an asset command to fail gracefully? For example, if the asset does not exist, it would be nice if it returned null. Another option would be to include another set of boolean commands such as image_exists, so this could be performed: