jekyll-image-size icon indicating copy to clipboard operation
jekyll-image-size copied to clipboard

Liquid Exception: undefined method `sub'

Open pnhofmann opened this issue 5 years ago • 1 comments

Hi!

crashes with Jekyll 4.0.0 on ruby 2.6.5p114 (arch linux):

Jekyll::Drops::StaticFileDrop  Liquid Exception: undefined method `sub' for #<Jekyll::Drops::StaticFileDrop:0x00005587c47f6fd8> in index.html

Works using this small patch:

diff --git a/lib/jekyll-image-size.rb b/lib/jekyll-image-size.rb
index ead00a0..560c911 100644
--- a/lib/jekyll-image-size.rb
+++ b/lib/jekyll-image-size.rb
@@ -32,7 +32,7 @@ class ImageSizeTag < Liquid::Tag
     size = FastImage.size(source)
     if context && !size
       if contextSource = rawSource = context[source]
-        contextSource = contextSource.sub(/^\//, '')
+        contextSource = contextSource.path.sub(/^\//, '')
         size = FastImage.size(contextSource)
       end
     end
(END)

But this crashes for older versions (#2)

Unfortunately don't really know ruby well so can't tell more...

pnhofmann avatar Dec 20 '19 09:12 pnhofmann