jekyll-assets
jekyll-assets copied to clipboard
Image Height/Width unavailable
Are there obvious conditions that would make the height and width of an asset unavailable? I am doing things like {% assets['foo.jpg'].height %}
in multiple Jekyll sites, on identical images, but in some the geometry data is nil and I'm not sure how to debug.
try {% assets['foo.jpg'].dimensions.height %}
That did the trick. Thanks @mittelgrau!
Oh wow, I didn't even see this ticket. Sorry about not responding...
I guess I'm still curious about the original question, but the suggestion to use dimensions
resolved the issue in the meantime
There isn't, it's a bug in my source
https://github.com/envygeeks/jekyll-assets/blob/498efc39896813c51045f1531fe1ab2e51a55827/lib/jekyll/assets/drop.rb#L19-L20
Should really have key: "width"
, because that rb_delegate
from Forwardable::Extended
will use :width
as the key, and it should always return nil, for everything but dimensions. If it's working in some cases and not, that's a corner that needs to be looked at independently but I would assume that the case is it always returns nil on newer versions of 3.x, newer versions moved that to a multi-way access for efficiency (read: only have to get the dimensions once, rather than twice.)
If you need a reproducible example, this is the site where I was running into issues.
I will use that to see if I can trace out a case for the sometimes nil, sometimes not. As for the fixing of the key, I'll update that in a few hours when I'm back at my laptop, and ping here when it's updated.