Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

link_to image_tag with options (rel, title)

In HTML I would write:

<div class="imageRow">
    <div class="single">
        <a href="image.jpg" rel="lightbox" title="my caption">
            <img alt="" src="imagethumb.jpg">
        </a>
    </div>
</div>

But I have to adapt it for ruby on rails and I'm quite new to it... so I tried:

<div class="imageRow">
    <div class="single">
        <a href=<%= link_to image_tag("image.jpg") %> rel="lightbox" title="my caption">
            <%= image_tag("imagethumb.jpg") %>
        </a>
    </div>
</div>

...but it doesn't work as the "rel="lightbox" title="my caption">" part is not applied but appears written on the html part + I see the 2 images while I should only see "imagethumb".

I also tried:

<div class="imageRow">
    <div class="single">
        <%= link_to image_tag("image.jpg", :rel=>"lightbox", :title=>"my caption")
            <%= image_tag("imagethumb.jpg") %>
        %>
    </div>
</div>

I see both image too...

What should I do to obtain the equivalent of the HTML code I wrote up?

like image 636
morg Avatar asked Jun 10 '13 15:06

morg


1 Answers

Try this

<%= link_to image_tag("imagethumb.png", :alt => ""), "image.jpg", :rel => "lightbox", :title => "my caption" %>

P.S: Untested

like image 110
usha Avatar answered Sep 20 '22 12:09

usha