【发布时间】:2020-06-19 09:22:00
【问题描述】:
我已经检查了this solution,它似乎对我的问题不起作用。我在将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) 来自this answer 的解决方案,不起作用
{% 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
【问题讨论】:
标签: jekyll github-pages liquid