Giter VIP home page Giter VIP logo

refinerycms-page-images's Introduction

Page Images Engine for Refinery CMS

About

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.

Requirements

  • refinerycms >= 3.0.0

Features

  • 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

Install

Add this line to your application's Gemfile

gem 'refinerycms-page-images', '~> 3.0.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 "127.0.0.1" 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

Note that WYMeditor support requires that you have the extension in your Gemfile:

gem 'refinerycms-wymeditor', '~> 1.0.0'

Usage

app/views/refinery/pages/show.html.erb

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| %>
      <li>
        <%= link_to image_tag(image.thumbnail(geometry: "200x200#c").url),
                    image.thumbnail(geometry: "900x600").url %>
      </li>
   <% end %>
  </ul>
<% end %>
<%= render :partial => "/refinery/content_page" %>

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

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

or like this

<% content_for :body_content_right do %>
  <section id='gallery'>
    <% @page.images_with_captions.each 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>
<% end %>
<%= render :partial => "/refinery/content_page" %>

Refinerycms-blog support

Contrary to its name, refinerycms-page-images also works with refinerycms-blog and adds the functionality to link images to blog posts.

If refinerycms-blog is installed on your rails app, refinerycms-page-images will automatically detect it and perform the adequate initialization. PageImages are assigned to a polymorph "page" object, wich can be a Refinery::Page or a Blog::Post.

Thus, once installed, you can simply call a blog post's images the same way you'd call them for a page, like this

<% @blog_posts.each do |blog_post| %>
  <ul id='gallery'>
    <% blog_post.images.each do |image| %>
      <li>
        <%= link_to image_tag(image.thumbnail(geometry: "200x200#c").url),
                    image.thumbnail(geometry: "900x600").url %>
      </li>
   <% end %>
  </ul>
<% end %>
<%= render :partial => "/refinery/content_page" %>

Screenshot

Refinery CMS Page Images Screenshot

refinerycms-page-images's People

Contributors

parndt avatar ugisozols avatar djones avatar wakeless avatar phiggins avatar anitagraham avatar bricesanchez avatar mhaylock avatar simi avatar mirosr avatar matho avatar davidbennettpio avatar bobbus avatar snowsunny avatar duarme avatar skeller1 avatar kovalevsky avatar richlarcombe avatar cerebroso avatar prokopsimek avatar peterberkenbosch avatar pedropag avatar akselsson avatar palodelincak avatar soupmatt avatar nowaterlili avatar kevinsmouts avatar jurriaan avatar jokklan avatar jamesantrobus avatar

Watchers

 avatar James Cloos avatar Alessandro Rodi avatar Marta Petrella avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.