diff --git a/app/controllers/galleries_controller.rb b/app/controllers/galleries_controller.rb index 1764c1a..6b2ae9e 100644 --- a/app/controllers/galleries_controller.rb +++ b/app/controllers/galleries_controller.rb @@ -49,7 +49,7 @@ class GalleriesController < ApplicationController thumb_src = a.cover_path(@image_version) if thumb_src thumb_srcs = thumb_src.split('/') - thumb_srcs[-1] = thumb_srcs[-1].sub(/^\w+_/,"") + thumb_srcs[-1] = thumb_srcs[-1].sub(/^(?:(?!_).)*_/,"") thumb_path = thumb_srcs[0..-2].join('/') thumb_path_name = thumb_srcs[-1] src = "#{thumb_path}/#{thumb_path_name}" diff --git a/app/models/album_image.rb b/app/models/album_image.rb index cca000a..b277f3f 100644 --- a/app/models/album_image.rb +++ b/app/models/album_image.rb @@ -37,6 +37,14 @@ class AlbumImage Album.where(:id=>self.album_id).update_all(:min_order=>min_order + 1) end end + before_save do + if self.file_changed? + cover = self.album['cover'] + if cover && cover == self.id + self.album.update_attributes({:cover_path => self.file.thumb.url, :cover=> self.id}) + end + end + end def title_translations tmp = super || {} if tmp == {}