fix the problem that when upload failed if will lead to not upload

success furthor more and let show description tag can also work for image
This commit is contained in:
chiu 2020-02-28 09:21:35 +08:00
parent b84c4af63a
commit d82207aa68
2 changed files with 25 additions and 24 deletions

View File

@ -473,11 +473,11 @@ class Admin::GalleriesController < OrbitAdminController
def upload_process
if AlbumUnprocess.first.upload_success
album_unprocess = AlbumUnprocess.all
album_unprocess = Array(AlbumUnprocess.all)
count = album_unprocess.count
Thread.new do
begin
album_unprocess.each_with_index do |un_image,i|
begin
album = AlbumImage.all.select{|value| value.id.to_s == un_image.image_id.to_s}[0]
album.file = un_image.save_var
album.save!
@ -489,9 +489,10 @@ class Admin::GalleriesController < OrbitAdminController
variable.progress_filename = album[:file]
variable.progress_percent = ((i+1)*100.0/count).floor.to_s + '%'
variable.save!
end
rescue => e
puts ['err',e.inspect]
puts ['err',un_image.inspect,e.inspect]
un_image.destroy
end
end
variable = AlbumVariable.first
variable.finish = true

View File

@ -63,7 +63,7 @@ class GalleriesController < ApplicationController
images = album.album_images.asc(:order).collect do |a|
alt_text = (a.description.nil? || a.description == "" ? "gallery image" : a.description)
{
"image-description" => a.description,
"image-description" => (flag ? a.description : ''),
"alt_title" => alt_text,
"link_to_show" => "/xhr/galleries/theater/" + a.id.to_s,
"thumb-src" => a.file.thumb.url