Skip to content

Commit 6eafef5

Browse files
committed
Change naming of 'grid_view' and 'list_view' to 'grid_format' and 'grid_view'.
(view, format and layout are already special words, and I may yet change format to something useful, but not duplicating a term used in another context) keep the format variable as a symbol wherever it is used. renamed configuration accessors to 'index_formats' (et al) to be clear about their function.
1 parent 8837cdc commit 6eafef5

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

images/app/controllers/refinery/admin/images_controller.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ImagesController < ::Refinery::AdminController
88
sortable: false,
99
conditions: 'parent_id IS NULL'
1010

11-
before_action :change_list_mode_if_specified, :init_dialog
11+
before_action :change_format_if_specified, :init_dialog
1212

1313
def new
1414
@image = ::Refinery::Image.new if @image.nil?
@@ -166,9 +166,12 @@ def init_dialog
166166
@conditions = params[:conditions]
167167
end
168168

169-
def change_list_mode_if_specified
170-
if action_name == 'index' && params[:view].present? && Refinery::Images.image_views.include?(params[:view].to_sym)
171-
Refinery::Images.preferred_image_view = params[:view]
169+
def change_format_if_specified
170+
return unless params[:format].present?
171+
172+
format = params[:format].to_sym
173+
if action_name == 'index' && format && Refinery::Images.index_formats.include?(format)
174+
Refinery::Images.preferred_index_format = format
172175
end
173176
end
174177

images/app/models/refinery/image.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def per_page(dialog = false, has_size_options = false)
4646

4747
# Get a thumbnail job object given a geometry and whether to strip image profiles and comments.
4848
def thumbnail(options = {})
49-
options = { geometry: nil, strip: false }.merge(options)
49+
options = { geometry: nil, strip: false, **options}
5050
geometry = convert_to_geometry(options[:geometry])
5151
thumbnail = image
5252
thumbnail = thumbnail.thumb(geometry) if geometry

images/app/viewobjects/image_object.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,22 @@ def initialize(image, context, scope=nil)
1515
end
1616

1717
def title
18-
translated_field(image, :title)
18+
translated_field(image, :image_title).titleize
1919
end
2020

2121
def alt
22-
translated_field(image, :alt)
22+
translated_field(image, :image_alt).titleize
2323
end
2424

25-
def img_element
26-
image_fu image, '149x149#c', title: ::I18n.t('edit_title', scope: i18n_scope, title: image.image_title || image.image_alt)
25+
def grid_image_attributes
26+
{ src: image.thumbnail(geometry: Refinery::Images.admin_image_sizes[:grid], strip: true).url,
27+
title: ::I18n.t('edit_title', scope: i18n_scope, title: title) }
2728
end
2829

2930
def filename
3031
image.image_name
3132
end
33+
3234
def locales_with_titles
3335
image.translations
3436
.reject { |i| i.image_title.blank? }

images/lib/refinery/images/configuration.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Images
66

77
config_accessor :max_image_size, :pages_per_dialog, :pages_per_admin_index,
88
:pages_per_dialog_that_have_size_options, :user_image_sizes, :user_image_ratios,
9-
:image_views, :preferred_image_view, :admin_image_sizes,
9+
:index_formats, :preferred_index_format, :admin_image_sizes,
1010
:allowed_mime_types, :allowed_mime_types_msg
1111

1212
self.max_image_size = 5_242_880
@@ -29,8 +29,8 @@ module Images
2929
}
3030
self.allowed_mime_types = %w[image/jpeg image/png image/gif image/tiff]
3131
self.allowed_mime_types_msg = self.allowed_mime_types.to_sentence(last_word_connector: ' or ')
32-
self.image_views = [:grid, :list]
33-
self.preferred_image_view = :grid
32+
self.index_formats = [:grid, :list]
33+
self.preferred_index_format = :grid
3434

3535
# Images should always use these changes to the dragonfly defaults
3636
self.dragonfly_name = :refinery_images

0 commit comments

Comments
 (0)