zoomifier/lib/zoomifier_helper.rb

17 lines
681 B
Ruby
Raw Normal View History

module Zoomifier
module ViewHelpers
2008-11-24 04:41:10 +00:00
def zoomify_image_tag(source, options = {})
2008-11-24 08:18:49 +00:00
raise ArgumentError unless [:id, :width, :height].all? {|o| options[o] }
2008-11-25 04:18:47 +00:00
if File.file?(path = RAILS_ROOT + '/public/images/' + source)
Zoomifier::zoomify(path)
end
2008-11-24 08:18:49 +00:00
s = content_tag :div, { :id => options[:id] } do
image_tag source, options.merge({ :id => nil })
end
2008-11-24 08:18:49 +00:00
zoomify_path = image_path(source).gsub(/\.[^.]+$/, '')
2008-11-25 04:18:47 +00:00
s += javascript_tag "swfobject.embedSWF('/swfs/zoomifyViewer.swf', '#{options[:id]}', '#{options[:width]}', '#{options[:height]}', '9.0.0', false, { zoomifyImagePath: '#{zoomify_path}/' });"
2008-11-24 08:18:49 +00:00
s
end
end
end