summaryrefslogtreecommitdiff
path: root/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'helpers')
-rw-r--r--helpers/extra_image_helpers.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/helpers/extra_image_helpers.rb b/helpers/extra_image_helpers.rb
new file mode 100644
index 0000000..9c92d3c
--- /dev/null
+++ b/helpers/extra_image_helpers.rb
@@ -0,0 +1,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