文字列の代わりに液体タグコール内部の使用変数

オンドレイ・Sevcik:

私はすでにチェックして、このソリューションを、それは私の問題のために動作するようには思えません。私は合格の問題を持っているpost.imageタグに変数名をresponsive_image私は、文字列を渡す場合はそのように{% responsive_image path: assets/img/ar-7.jpg %}それはどんな問題なく動作しますが、私はどのように変数を渡す方法が見つかりませんでした。何か案は?

1)私は残念ながら、文字列は、これが機能するだろうと思ったpost.imageの代わりに変数を渡されます。コメントのコードは、私が対応する画像に変更する必要があることを例に取り組んでいます。

 {% if post.image %}
  {% responsive_image path: post.image %}
  <!-- <img class="has-ratio" src="{{post.image}}" /> -->
 {% endif %}
Invalid image path specified: "post.image" 
  Liquid Exception: unable to open image `/Users/.../Documents/Apps/Jekyll/wtc-mbp/post.image': No such file or directory @ error/blob.c/OpenBlob/2881 in .html

2)からソリューションこの答えは、仕事をしません

 {% if post.image %}
  {% assign path = post.image %}
  {% responsive_image path %}
 {% endif %}
Invalid image path specified: nil 
  Liquid Exception: no decode delegate for this image format `' @ error/constitute.c/ReadImage/566 in .html

3)もう一つのアイデアも仕事はしていません

 {% if post.image %}
  {% assign path = post.image %}
  {% responsive_image path: path %}
 {% endif %}
Invalid image path specified: "path" 
Liquid Exception: unable to open image `/Users/.../Documents/Apps/Jekyll/wtc-mbp/path': No such file or directory @ error/blob.c/OpenBlob/2881 in .html
ashmaroli:

液体の変数を使用するには、を選ぶ必要があるresponsive_image_block代わりにタグ:

{% responsive_image_block %}
  path: {{ post.image }}
{% endresponsive_image_block %}

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=28395&siteId=1