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

images_with_captions not retrieving anything on the frontend #109

Closed denisinla closed 6 years ago

denisinla commented 10 years ago

After trying to make usage of the images_with_captions object and following the guide for displaying all my images as follows:

<section id='gallery'>
    <% @page.images_with_captions do |iwc| %>
      <figure>
        <%= link_to image_tag(iwc.image.thumbnail(geometry: "200x200#c").url),
                    iwc.image.thumbnail(geometry: "900x600").url %>
        <figcaption><%=raw iwc.caption %></figcaption>
      </figure>
   <% end %>
  </section>

Nothing seems to be rendering on the frontend. I noticed that new code was checked in 26 days ago for this, but currently it's not rendering at all.

ml242 commented 10 years ago

+1, I am getting captions with a helper method defining an array of recent posts but not in the way you describe above.... did you resolve your issue?

  <% @gallery_recent.each do |gallery| %>
    <figure class="grid col-one-quarter mq2-col-one-half">
      <a href="/ <%= gallery.path %> ">
      <%= image_tag(gallery.images.first.thumbnail(geometry: "246x184").url) %>
      <span class="zoom"></span>
      </a>
      <figcaption>
         <a href="<%= gallery.path%>" class="arrow"><%= gallery.title %></a> 
        <p><%= gallery.caption_for_image_index(0).html_safe %></p> 
       </figcaption>
     </figure>

Otherwise in my view I'm getting method_missing errors for each of the examples on the front page done the same way.

ml242 commented 10 years ago

Or with vanilla ruby:

<% @page.images.each_with_index do |image, i| %>
      <figure class="">
        <a href="<%= image.image_name %>" name="<%= image.image_name %>">
          <img src="<%= image.image_uid %>" alt="<%= image.image_name %>" >
        </a>
        <figcaption>
             <p><%= @page.caption_for_image_index(i).html_safe %></p>
        </figcaption>
       </figure>
    <% end %>
ml242 commented 10 years ago

Just noticed that this will not work for the last place in the array for some reason. ^^^

ml242 commented 10 years ago

and yeah, still getting a method missing.

anitagraham commented 10 years ago

Which version of refinerycms-page-images are you using? Images with captions are in the master branch.

anitagraham commented 10 years ago

I have updated the example code for images_with_captions, which was missing an each. It now reads

  <ul id='gallery'>
    <% @page.images_with_captions.each do |iwc| %>
      <li>
        <%= link_to image_tag(iwc[:image].thumbnail(geometry: "200x200#c").url),
                    iwc[:image].thumbnail(geometry: "900x600").url %>
        <span class='caption'><%=raw iwc[:caption] %></span>
      </li>
   <% end %>
  </ul>

Also changed the references within each iwc to iwc[:field] format