[Experimental] enable internal caching of responsive_image_block tag results
This commit is contained in:
parent
1565091d6e
commit
c9b9c97faf
|
@ -4,20 +4,30 @@ module Jekyll
|
||||||
include Jekyll::ResponsiveImage::Common
|
include Jekyll::ResponsiveImage::Common
|
||||||
|
|
||||||
def render(context)
|
def render(context)
|
||||||
site = context.registers[:site]
|
|
||||||
config = make_config(site)
|
|
||||||
|
|
||||||
attributes = YAML.load(super)
|
attributes = YAML.load(super)
|
||||||
image_template = attributes['template'] || config['template']
|
|
||||||
|
|
||||||
image = ImageProcessor.process(attributes['path'], config)
|
cache_key = attributes.to_s
|
||||||
attributes['original'] = image[:original]
|
result = attributes['cache'] ? RenderCache.get(cache_key) : nil
|
||||||
attributes['resized'] = image[:resized]
|
|
||||||
|
|
||||||
partial = File.read(image_template)
|
if result.nil?
|
||||||
template = Liquid::Template.parse(partial)
|
site = context.registers[:site]
|
||||||
|
config = make_config(site)
|
||||||
|
|
||||||
template.render!(attributes.merge(site.site_payload))
|
image_template = attributes['template'] || config['template']
|
||||||
|
|
||||||
|
image = ImageProcessor.process(attributes['path'], config)
|
||||||
|
attributes['original'] = image[:original]
|
||||||
|
attributes['resized'] = image[:resized]
|
||||||
|
|
||||||
|
partial = File.read(image_template)
|
||||||
|
template = Liquid::Template.parse(partial)
|
||||||
|
|
||||||
|
result = template.render!(attributes.merge(site.site_payload))
|
||||||
|
|
||||||
|
RenderCache.set(cache_key, result)
|
||||||
|
end
|
||||||
|
|
||||||
|
result
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue