blob: 9c92d3cc3e1ade2b28dbffef654f99306c019f7d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
module ExtraImageHelpers
# creates a div with image link, thumbnail and caption
# TODO make this work for non-image assets (pdf on 'verein' page)
def image_with_thumb(name, options={})
caption = options.delete(:caption)
full_path = "/img/#{name}"
thumb_name = options.delete(:thumbnail) || default_thumbnail_for(name)
thumb_path = "/img/#{thumb_name}"
# oh boy, padrino-helpers has problems with nested content_for... FIXME
thumb_tag = image_tag(thumb_path, options)
image_link = content_tag(:a, thumb_tag, href: full_path)
caption_tag = content_tag(:p, caption)
content_tag :div, [image_link, caption_tag].join("\n")
end
private
def default_thumbnail_for(image_name_with_ext)
name, ext = image_name_with_ext.split(".")
"#{name}_klein.#{ext}"
end
end
|