Fixes for bootstrap-sass used without Rails

Two major changes:

1. Improve the load logic to take into account that Sprockets might be used without Rails. Simplify and DRY it up. It should have exactly the same effect as before, with the exception that `rails_functions.rb` is now only loaded if ::Rails is defined.
2. Improve the `image_path