Commit 101559cf authored by Martin Markech's avatar Martin Markech
Browse files

Merge pull request #6 from QEDio/link_url_for_photo

Added an url field for photo which, if specified, will be used for the l...
parents 7fa89a03 ef8cf3b4
......@@ -5,7 +5,7 @@ module Refinery
mount_uploader :file, Refinery::PhotoGallery::Admin::FileUploader
acts_as_indexed :fields => [:title, :description]
attr_accessible :album_id, :title, :description, :longitude, :latitude
attr_accessible :album_id, :title, :description, :longitude, :latitude, :url
validates :title, :presence => true
#TODO validate latitude/longitude - convert from nondecimal to decimal using inspiration from https://github.com/airblade/geo_tools/tree/master/lib/geo_tools
......@@ -20,6 +20,10 @@ module Refinery
"#{id}-#{title.parameterize}"
end
def link_url
self.url.blank? ? file.single.url : self.url
end
private
def set_title
......
......@@ -15,6 +15,11 @@
<%= p.text_area :description, :rows => "5", :cols=> "57" %>
</div>
<div class='field'>
<%= p.label :url %>
<%= p.text_field :url, :class => "larger" %>
</div>
<div class='field-group'>
<%= p.label :longitude, :tooltip=> t('.use_decimal_format') %>
<%= p.text_field :longitude, :size=> 13 %>
......
......@@ -6,7 +6,7 @@
<ul id="gallery" class="clearfix">
<% photos_for_page.each_with_index do |photo, index| %>
<li>
<%= link_to (image_tag photo.file.url(:album), :width => Refinery::PhotoGallery.album_dimensions[0], :height => Refinery::PhotoGallery.album_dimensions[1] ), photo.file.single.url, {
<%= link_to (image_tag photo.file.url(:album), :width => Refinery::PhotoGallery.album_dimensions[0], :height => Refinery::PhotoGallery.album_dimensions[1] ), photo.link_url, {
:target=> "_blank",
:class=>"fancybox",
:data =>{:title=> t('.image') + ' ' + (index + 1 ).to_s + '/' + photos_for_page.total_pages.to_s + ' ' + photo.title + '<br/><br/>' + photo.description},
......
class AddUrlToPhotos < ActiveRecord::Migration
def change
add_column :refinery_photo_gallery_photos, :url, :string
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment