add thumb process option setting
This commit is contained in:
parent
82809c20cf
commit
92e2673c09
|
@ -15,6 +15,7 @@ class Album
|
|||
field :order, type: Integer, default: -1
|
||||
field :min_order, type: Integer, default: -1
|
||||
field :resize_gravity
|
||||
field :thumb_process_option, type: Integer, default: 0
|
||||
# has_and_belongs_to_many :tags, :class_name => "GalleryTag"
|
||||
has_many :album_images, :autosave => true, :dependent => :destroy
|
||||
has_many :album_colors, :autosave => true, :dependent => :destroy
|
||||
|
|
|
@ -13,7 +13,7 @@ class GalleryUploader < CarrierWave::Uploader::Base
|
|||
# Include RMagick or ImageScience support:
|
||||
# include CarrierWave::RMagick
|
||||
# include CarrierWave::ImageScience
|
||||
include CarrierWave::MiniMagick
|
||||
include CarrierWave::MiniMagick
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
# storage :file
|
||||
# storage :s3
|
||||
|
@ -68,11 +68,11 @@ class GalleryUploader < CarrierWave::Uploader::Base
|
|||
end
|
||||
version :thumb do
|
||||
process :convert => 'png', :if => :transparent?
|
||||
process :pad_process => [200,200]
|
||||
process :thumb_process => [200, 200]
|
||||
end
|
||||
version :thumb_large do
|
||||
process :convert => 'png', :if => :transparent?
|
||||
process :pad_process => [600,600]
|
||||
process :thumb_process => [600, 600]
|
||||
end
|
||||
version :theater do
|
||||
process :limit_process => [1920, 1080]
|
||||
|
@ -175,9 +175,14 @@ class GalleryUploader < CarrierWave::Uploader::Base
|
|||
now_album = model.album
|
||||
now_album.album_colors.first['color']=='transparent' rescue true
|
||||
end
|
||||
def pad_process (w,h)
|
||||
def thumb_process(w,h)
|
||||
now_album = model.album
|
||||
resize_and_pad(w, h, (transparent? ? :transparent : now_album.album_colors.first['color']), (now_album.resize_gravity rescue 'Center'))
|
||||
case now_album.thumb_process_option
|
||||
when 0
|
||||
resize_and_pad(w, h, (transparent? ? :transparent : now_album.album_colors.first['color']), (now_album.resize_gravity rescue 'Center'))
|
||||
when 1
|
||||
limit_process(w, h)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -59,7 +59,11 @@ input.minicolors-input{
|
|||
}
|
||||
})
|
||||
return true
|
||||
})
|
||||
});
|
||||
$('#album_thumb_process_option').change(function(){
|
||||
$('.thumb_process_option').hide();
|
||||
$('.thumb_process_option'+'.'+$(this).val()).show();
|
||||
}).trigger('change');
|
||||
});
|
||||
</script>
|
||||
<fieldset>
|
||||
|
@ -76,7 +80,7 @@ input.minicolors-input{
|
|||
<a href="#tag" data-toggle="tab"><%= t(:tags) %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#frame_color" data-toggle="tab"><%= t('gallery.recreate_thumb') %></a>
|
||||
<a href="#advanced_setting" data-toggle="tab"><%= t('gallery.advanced_setting') %></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
@ -108,43 +112,50 @@ input.minicolors-input{
|
|||
<% if @album.album_colors.first.nil? %>
|
||||
<% @album.album_colors.new('color' => 'transparent') %>
|
||||
<% end %>
|
||||
<%= f.fields_for :album_colors do |album_color_form| %>
|
||||
<div class="tab-pane fade" id="frame_color">
|
||||
<!-- Frame Color -->
|
||||
<div class="control-group" style='display: flex;'>
|
||||
<label class="control-label muted"><%= t('gallery.recreate_thumb') %></label>
|
||||
<%= album_color_form.text_field :color , :class => 'input-block-level minicolors-input' %>
|
||||
<span style='font-size: 20px;display: flex;align-items: center;'>
|
||||
<input type='checkbox' onchange='set_transparent(this)' style='width: 18px;height: 18px;margin: 0;'>
|
||||
<%= t('gallery.transparent') %>
|
||||
</span>
|
||||
</div>
|
||||
<div class="control-group" style='display: flex;'>
|
||||
<label class="control-label muted"><%= t('gallery.album_card_background_color') %></label>
|
||||
<%= album_color_form.text_field :album_card_background_color, :class => 'input-block-level minicolors-input' %>
|
||||
<span style='font-size: 20px;display: flex;align-items: center;'>
|
||||
<input type='checkbox' onchange='set_transparent(this)' style='width: 18px;height: 18px;margin: 0;'>
|
||||
<%= t('gallery.transparent') %>
|
||||
</span>
|
||||
</div>
|
||||
<div class="control-group" style='display: flex;'>
|
||||
<label class="control-label muted"><%= t('gallery.album_card_text_color') %></label>
|
||||
<%= album_color_form.text_field :album_card_text_color, :class => 'input-block-level minicolors-input' %>
|
||||
<span style='font-size: 20px;display: flex;align-items: center;'>
|
||||
<input type='checkbox' onchange='set_transparent(this)' style='width: 18px;height: 18px;margin: 0;'>
|
||||
<%= t('gallery.transparent') %>
|
||||
</span>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted">
|
||||
<%= t('gallery.thumb_resize_reference') %>
|
||||
</label>
|
||||
<div class="controls">
|
||||
<%= f.select :resize_gravity, [["---#{t("default")}: #{t("gallery.gravity.#{AlbumSetting::ResizeGravities[0]}")}---",nil]]+AlbumSetting::ResizeGravities.collect{|v| [t("gallery.gravity.#{v}"),v]} %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="advanced_setting">
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t('gallery.thumb_process_option_trans') %></label>
|
||||
<div class="controls">
|
||||
<%= f.select :thumb_process_option, t('gallery.thumb_process_option').to_enum.with_index.collect{|v, i| [v, i]} %>
|
||||
</div>
|
||||
</div>
|
||||
<%= f.fields_for :album_colors do |album_color_form| %>
|
||||
|
||||
<!-- Frame Color -->
|
||||
<div class="control-group thumb_process_option 0" style='display: flex;'>
|
||||
<label class="control-label muted"><%= t('gallery.frame_color') %></label>
|
||||
<%= album_color_form.text_field :color , :class => 'input-block-level minicolors-input' %>
|
||||
<span style='font-size: 20px;display: flex;align-items: center;'>
|
||||
<input type='checkbox' onchange='set_transparent(this)' style='width: 18px;height: 18px;margin: 0;'>
|
||||
<%= t('gallery.transparent') %>
|
||||
</span>
|
||||
</div>
|
||||
<div class="control-group thumb_process_option 0">
|
||||
<label class="control-label muted">
|
||||
<%= t('gallery.thumb_resize_reference') %>
|
||||
</label>
|
||||
<div class="controls">
|
||||
<%= f.select :resize_gravity, [["---#{t("default")}: #{t("gallery.gravity.#{AlbumSetting::ResizeGravities[0]}")}---",nil]]+AlbumSetting::ResizeGravities.collect{|v| [t("gallery.gravity.#{v}"),v]} %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" style='display: flex;'>
|
||||
<label class="control-label muted"><%= t('gallery.album_card_background_color') %></label>
|
||||
<%= album_color_form.text_field :album_card_background_color, :class => 'input-block-level minicolors-input' %>
|
||||
<span style='font-size: 20px;display: flex;align-items: center;'>
|
||||
<input type='checkbox' onchange='set_transparent(this)' style='width: 18px;height: 18px;margin: 0;'>
|
||||
<%= t('gallery.transparent') %>
|
||||
</span>
|
||||
</div>
|
||||
<div class="control-group" style='display: flex;'>
|
||||
<label class="control-label muted"><%= t('gallery.album_card_text_color') %></label>
|
||||
<%= album_color_form.text_field :album_card_text_color, :class => 'input-block-level minicolors-input' %>
|
||||
<span style='font-size: 20px;display: flex;align-items: center;'>
|
||||
<input type='checkbox' onchange='set_transparent(this)' style='width: 18px;height: 18px;margin: 0;'>
|
||||
<%= t('gallery.transparent') %>
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='input-area'>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<form method="get" action="/admin/galleries/recreate_image?" name="thumb_recreate_form"
|
||||
style='display: block;display: inline-flex;flex-wrap: wrap;align-items: center;width: 100%;'>
|
||||
<span style="display:inline-flex;align-items:center;padding:0 1%;height:34px;font-size: 1.5em;">
|
||||
<%= t('gallery.recreate_thumb')+':' %>
|
||||
<%= t('gallery.frame_color')+':' %>
|
||||
</span>
|
||||
<input style='height:26px;max-width: 80%;' class='minicolors-input' type="text" name="color_choice" value="<%= @color_save.to_s %>" autocomplete="off">
|
||||
<span style='font-size: 20px;'>
|
||||
|
|
|
@ -2,6 +2,11 @@ en:
|
|||
|
||||
gallery:
|
||||
setting: Gallery Setting
|
||||
advanced_setting: Advanced Setting
|
||||
thumb_process_option_trans: Thumb Process Option
|
||||
thumb_process_option:
|
||||
- resize and padding
|
||||
- resize only
|
||||
inner_page_layout: Inner Page Layout
|
||||
card_style: Card Style
|
||||
grid_style: Grid Style
|
||||
|
@ -59,7 +64,7 @@ en:
|
|||
progressbar: 'Progress bar'
|
||||
error: 'Recreate thumb failed, please contact service agent or try again later'
|
||||
'sure?': 'Are yoy sure to apply? it will recreate all the thumbs of you choose'
|
||||
recreate_thumb: 'Frame color'
|
||||
frame_color: 'Frame color'
|
||||
'recreate': 'Apply'
|
||||
transparent: transparent
|
||||
checked: select all
|
||||
|
|
|
@ -2,6 +2,11 @@ zh_tw:
|
|||
|
||||
gallery:
|
||||
setting: 相簿設定
|
||||
advanced_setting: 進階設定
|
||||
thumb_process_option_trans: 縮圖處理選項
|
||||
thumb_process_option:
|
||||
- 縮放並填充
|
||||
- 僅縮放
|
||||
inner_page_layout: 內頁頁面樣式
|
||||
card_style: 卡片樣式
|
||||
grid_style: 格子排版樣式
|
||||
|
@ -61,7 +66,7 @@ zh_tw:
|
|||
progressbar: 進度條
|
||||
error: '重新產生縮圖失敗,請聯絡客服或稍後再試'
|
||||
'sure?': '您真的确定要套用嗎? 會重新產生整個相簿的縮圖喔!'
|
||||
recreate_thumb: 相框底色
|
||||
frame_color: 相框底色
|
||||
transparent: 透明
|
||||
checked: 全選
|
||||
unchecked: 全部反選
|
||||
|
|
Loading…
Reference in New Issue