Sha256: 0d0dcbcb483a754410e1daaddaf66888f48bad34840badf602708c0262ddb3ef
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
# Frozen-string-literal: true # Copyright: 2012-2015 - MIT License # Encoding: utf-8 require "fastimage" module Jekyll module Assets module Liquid class Drop < ::Liquid::Drop extend Forwardable def initialize(path, jekyll) @path = path @jekyll = jekyll @asset = nil end def_delegator :asset, :logical_path def_delegator :asset, :content_type, :type def_delegator :asset, :content_type def_delegator :asset, :filename def basename File.basename(@path) end def width if image? dimensions.first end end def height if image? dimensions.last end end def dimensions if image? @dimensions ||= FastImage.new(asset.filename).size end end private def image? %W(image/png image/jpeg image/gif).include?( asset.content_type ) end private def asset @asset ||= @jekyll.sprockets.find_asset(@path) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jekyll-assets-2.1.3 | lib/jekyll/assets/liquid/drop.rb |
jekyll-assets-2.1.2 | lib/jekyll/assets/liquid/drop.rb |