<script type="text/javascript">
<%
base_path = "#{Rails.root}/app/assets/images/"
imgs = Dir.glob("#{base_path}**/*").each_with_object({}) do |f, h|
  next if File.directory?(f)
  relative = f.sub(base_path, '')
  h[relative] = image_path(relative)
end
%>

window.image_path = function(name){
  return <%= raw imgs.to_json %>[name];
}
</script>
