Adds an images tab to your pages so you can format a group of images really nicely on the frontend
Ruby CSS
Pull request Compare This branch is 50 commits behind refinery:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Page Images Engine for Refinery CMS


Page Images allows you to relate one or more images to any page in Refinery which makes it really easy for you to create simple image galleries with lightbox style popups on the front end page views.


  • refinerycms >= 2.1.0


  • Ability to select one or more images from the image picker and assign them to a page
  • An image can be assigned to more than one page
  • Reordering support, simply drag into order
  • An image assigned to a page can have a caption.
  • An image's caption can be different for different pages


Add this line to your applications Gemfile

gem 'refinerycms-page-images', '~> 2.1.0'

Next run

bundle install
rails generate refinery:page_images
rake db:migrate

Now when you start up your Refinery application, edit a page and there should be a new "Images" tab.

Deploying to Heroku

In order to properly precompile assets on Heroku, config vars must be present in the environment during slug compilation.

heroku labs:enable user-env-compile -a myapp

otherwise you may experience the following error:

could not connect to server: Connection refused
Is the server running on host "" and accepting
TCP/IP connections on port 5432?

More Details

Enable Captions

You can enable captions using an initializer containing the following configuration:

# app/config/initializers/refinery/page-images.rb
Refinery::PageImages.captions = true

By default, captions are WYM editors. Prefer textareas? Gotcha :

Refinery::PageImages.wysiwyg = false



If you don't have this file then Refinery will be using its default. You can override this with

rake refinery:override view=refinery/pages/show

If images have been assigned to a page several objects are available for showing on the page. They are

  • @page.images: A collection of images assigned to the page.
  • @page.caption_for_image_index(i) will return the caption (if any) for the ith image in @page.images
  • @page.images_with_captions: A collection of image_with_caption objects with the attributes image: and caption:
<% content_for :body_content_right do %>
  <ul id='gallery'>
    <% @page.images.each do |image| %>
        <%= link_to image_tag(image.thumbnail(geometry: "200x200#c").url),
                    image.thumbnail(geometry: "900x600").url %>
   <% end %>
<% end %>
<%= render :partial => "/refinery/content_page" %>

If you have enabled captions, you can show them like this

<% content_for :body_content_right do %>
  <ul id='gallery'>
    <% @page.images.each_with_index do |image, index| %>
        <%= link_to image_tag(image.thumbnail(geometry: "200x200#c").url),
                    image.thumbnail(geometry: "900x600").url %>
        <span class='caption'><%=raw @page.caption_for_image_index(index) %></span>
   <% end %>
<% end %>
<%= render :partial => "/refinery/content_page" %>

or like this

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


Refinery CMS Page Images Screenshot