Reputation: 16226
I'm using slimbox2 with rails. To make it work you include some markup as follows:
<a href="resources/images/weight1.jpg" rel="lightbox-a" title="Beautiful, isn't it?">a</a>
<a href="resources/images/example.jpg" rel="lightbox-a" title="Beautiful, isn't it?">a</a>
So I'm wondering, how do you grab the location of the image to place in the href? Relative addressing? Is their a helper that is useful in this situation?
Upvotes: 2
Views: 12685
Reputation: 5002
Well, assuming the images were in your public/images folder, you could achieve that with something like
<%= link_to 'a', image_path('weight1.jpg'), :rel => 'lightbox-a', :title => 'some title' %>
Upvotes: 1
Reputation: 3275
You want the path of an image? You might try the aptly named #image_path helper method.
Upvotes: 12
Reputation: 654
You could use something like this. The helper is marginally useful. Honestly, unless there's some dynamic component, there's nothing wrong with just using HTML
link_to("a","/resources/images/weight1.jpg", :rel=>"lightbox-a", :title=>"Beautiful, isn't it?")
If the image is dynamic, you could always assign a variable with the path to the image (determined how you like)
<a href="<%= @image_path %>" rel="lightbox-a" title="Foo" />a</a>
Upvotes: 1