html 循环遍历文件夹中的所有图像

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 循环遍历文件夹中的所有图像相关的知识,希望对你有一定的参考价值。

<!--
My images are in a assets/images/slider directory.
-->

{% for image in site.static_files %}
  {% if image.path contains 'images/slider' %}
    <img src="{{ site.baseurl }}{{ image.path }}" alt="image" />
  {% endif %}
{% endfor %}

<!--
The image.path contains 'images/slider' makes sure that only images in that folder are inserted.
-->

<!--
Listing the jpg files in the current directory in Jekyll can also be done like this:
-->

{% for file in site.static_files %}
  {% assign pageurl = page.url | replace: 'index.html', '' %}
  {% if file.path contains pageurl %}
    {% if file.extname == '.jpg' or file.extname == '.jpeg' or file.extname == '.JPG' or file.extname == '.JPEG' %}
    <img src="{{ file.path }}" />
    {% endif %}
  {% endif %}
{% endfor %}

以上是关于html 循环遍历文件夹中的所有图像的主要内容,如果未能解决你的问题,请参考以下文章