0

I have a thumbnail image that links to a blog post entry which is accompanied by a text title. The CSS shades the image slightly and when the user hovers over the image, it re-sizes the image slightly. The user can click on the title or on the thumbnail to take them to the entry.

I cannot get the overlay tag here:

 <a href="single.html" class="overlay overlay-primary"></a>

to be generated within rails link_to

 <%= link_to(:class=>"overlay overlay-primary", id: entry) %>

The image is part of a figure

 <figure class="entry-thumbnail">

    <a href="single.html" class="overlay overlay-primary"></a>

    <!-- to disable lazy loading, remove data-src and data-src-retina -->
    <% if entry.cover_photo_link.blank? %>
        <%= image_tag "placeholder.gif" %>
    <% else %>
        <%= image_tag entry.cover_photo_link %>
    <% end %>
    <!--fallback for no javascript browsers-->
    <noscript>
      <% if entry.cover_photo_link.blank? %>
          <%= image_tag "placeholder.gif" %>
      <% else %>
          <%= image_tag entry.cover_photo_link %>
      <% end %>
    </noscript>

  </figure>

The full thumbnail codes is in this gist

How do I get the image to link to use link_to render this?

  <a href="single.html" class="overlay overlay-primary"></a> 

DogEatDog
  • 2,899
  • 2
  • 36
  • 65

1 Answers1

0

The solution was simple. Putting the a blank "" in link_to did the trick

<%= link_to "", entry, :class => "overlay overlay-primary" %>

renders:

 <a class="overlay overlay-primary" href="/entries/5"></a>

This worked well.

DogEatDog
  • 2,899
  • 2
  • 36
  • 65