Edit: I found the issue looking at your source code.
The problem is that I had the code below in a loop, but hadn’t yet provided the preview.jpeg
for every element in the loop. So your plugin would encounter a file path where the file does not exist. Your plugin decides, this is a severe error and raises exception stopping the build process. So I had to provide a dummy preview picture for all other elements in the loop to get it working.
It does not get to actually display the warning it’s supposed to:
raise "#{source_[path]} is not readable" unless File.readable?(source_path)
because the variable source_
apparently does not exist.
You might want to consider to just out put a red warning in the log instead of stopping to build altogether. Other than that, great work, thanks!
Original:
Hey, I tried your plugin, but I’m getting an error that might be just me not knowing the right syntax or an actual bug. Here’s what happens:
This is the code I use to show the preview thumbnails:
{% assign postDir = post.date | date: "%Y-%m-%d-" | append: post.slug %}
{% assign imgPath = "assets/images/posts/" | append: postDir | append: "/preview.jpeg" %}
<div class="image" style="background-image: url({{imgPath | resize: "800x800"}})">
</div>
This causes build error:
Liquid Exception: undefined local variable or method `source_' for #<#<Class:0x00000000074501d0>:0x00000000093e7f70> Did you mean? source in E:/Repos/my_page/_pages/blog.html
Error: undefined local variable or method `source_' for #<#<Class:0x00000000074501d0>:0x00000000093e7f70> Did you mean? source
Error: Run jekyll build --trace for more information.
However, without the filter it works fine and the image is displayed:
{% assign postDir = post.date | date: "%Y-%m-%d-" | append: post.slug %}
{% assign imgPath = "assets/images/posts/" | append: postDir | append: "/preview.jpeg" %}
<div class="image" style="background-image: url({{imgPath}})">
</div>
And when I just hardcode the string it works as well and the actual downscaled image is displayed:
{% assign postDir = post.date | date: "%Y-%m-%d-" | append: post.slug %}
{% assign imgPath = "assets/images/posts/" | append: postDir | append: "/preview.jpeg" %}
<div class="image" style="background-image: url({{"/assets/images/posts/2020-06-23-my-post/preview.jpeg" | resize: "800x800"}})">
</div>