refinery / refinerycms-page-images

Adds an images tab to your pages so you can format a group of images really nicely on the frontend
104 stars 120 forks source link

captions do not work #64

Closed dgdsp closed 12 years ago

dgdsp commented 12 years ago
<% @page.images.each do |i| %>
    <%= link_to(i.url, :class => "figure", :title => "click to enlarge") do %>
        <figure>
            <%= image_tag(i.thumbnail("200x200#c").url, :class => "thumbnail", :alt => strip_tags(i.caption) ) %>
            <figcaption>
                <%= raw i.caption %>
            </figcaption>
        <figure>
    <% end %>
<% end %>

raises

undefined method `caption'
parndt commented 12 years ago

The caption exists on the relationship so instead of .images use .image_pages

E.g.

<% @page.image_pages.each do |i| %>
  <%= link_to(i.image.url, :class => "figure", :title => "click to enlarge") do %>
    <figure>
      <%= image_tag(i.image.thumbnail("200x200#c").url, :class => "thumbnail", :alt => strip_tags(i.caption) ) %>
      <figcaption>
        <%= raw i.caption %>
      </figcaption>
    <figure>
  <% end %>
<% end %>
parndt commented 12 years ago

If somebody would like to please document this in the readme that would solve this issue.

dgdsp commented 12 years ago

thank you!

fyi, the correct code would be:

<% @page.image_pages.each do |i| %>
    <%= link_to(i.image.url, :class => "figure", :title => "click to enlarge") do %>
        <figure>
            <%= image_tag(i.image.thumbnail("200x200#c").url, :class => "thumbnail", :alt => strip_tags(i.caption) ) %>
            <figcaption>
                <%= raw i.caption %>
            </figcaption>
        <figure>
    <% end %>
<% end %>
parndt commented 12 years ago

Yes, that's the exact code I gave you ;-)

dgdsp commented 12 years ago

ah, true. it's a little late ;-)

On 04.04.2012, at 04:19, Philip Arndt wrote:

Yes, that's the exact code I gave you ;-)


Reply to this email directly or view it on GitHub: https://github.com/resolve/refinerycms-page-images/issues/64#issuecomment-4946133