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