Sha256: ceb7dd30cfc360fdcf50182e48f1430e9698419b3ac9e740bc37640328b07006
Contents?: true
Size: 1.91 KB
Versions: 3
Compression:
Stored size: 1.91 KB
Contents
# Frozen-string-literal: true # Copyright: 2012 - 2016 - 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, :digest_path 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 integrity return asset.integrity end # -------------------------------------------------------------------- def width if image? dimensions.first end end # -------------------------------------------------------------------- def height if image? dimensions.last end end # -------------------------------------------------------------------- def dimensions if image? @dimensions ||= FastImage.size(asset.filename.to_s) end end # -------------------------------------------------------------------- private def image? %W(image/png image/jpeg image/gif).include?( asset.content_type ) end # -------------------------------------------------------------------- private def asset @asset ||= @jekyll.sprockets.manifest.find(@path) \ .first end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
jekyll-assets-2.4.0 | lib/jekyll/assets/liquid/drop.rb |
jekyll-assets-2.3.2 | lib/jekyll/assets/liquid/drop.rb |
jekyll-assets-2.3.0 | lib/jekyll/assets/liquid/drop.rb |