Permalink
Browse files

enabled album art uploader

  • Loading branch information...
1 parent 359be96 commit d4d543ad4e0c153b1921275007ebb78237340241 @drtoast committed Mar 5, 2011
Showing with 7 additions and 4 deletions.
  1. +1 −1 app/controllers/albums_controller.rb
  2. +5 −3 app/models/album.rb
  3. +1 −0 app/views/albums/_album_art.haml
View
2 app/controllers/albums_controller.rb
@@ -134,7 +134,7 @@ def upload_cover
@album.cover = nil
file = params[:file]
ext = File.extname(file.original_filename)[1..-1]
- @album.add_cover(file.local_path, ext)
+ @album.add_cover(file.path, ext, false) # TODO: segfault when processing thumbnail in mongrel
logger.info "*** FILE: #{file.original_filename}, #{file.path}, #{file.inspect}"
if @album.save
# TODO: ajax upload doesn't work
View
8 app/models/album.rb
@@ -55,12 +55,14 @@ def extract_cover(replace_cover=true)
end
# resize and attach the image at the raw path
- def add_cover(original, format=nil)
+ def add_cover(original, format=nil, thumb=true)
processor = Toastunes::ImageProcessor.new
full_path = processor.save_cover(id, original, format)
- thumbnail_path = processor.write_thumbnail(id, full_path)
self.cover = File.basename(full_path)
- self.thumbnail = File.basename(thumbnail_path)
+ if thumb
+ thumbnail_path = processor.write_thumbnail(id, full_path)
+ self.thumbnail = File.basename(thumbnail_path)
+ end
end
def download_cover(url)
View
1 app/views/albums/_album_art.haml
@@ -9,4 +9,5 @@
.error= error
- if album.cover_download_at
.error= "Last checked on #{album.cover_download_at.strftime("%m/%d/%Y")}"
+ = render :partial => "album_cover_upload", :locals => {:album => album}
.clear

0 comments on commit d4d543a

Please sign in to comment.