Fix tempfile cannot read.
This commit is contained in:
parent
6e9c00464d
commit
f682f99975
|
@ -46,6 +46,7 @@ class PageContentsController < OrbitAdminController
|
||||||
image_file = Tempfile.new
|
image_file = Tempfile.new
|
||||||
image_file.binmode
|
image_file.binmode
|
||||||
image_file.write(res.body)
|
image_file.write(res.body)
|
||||||
|
image_file.close
|
||||||
begin
|
begin
|
||||||
image = MiniMagick::Image.open(image_file.path)
|
image = MiniMagick::Image.open(image_file.path)
|
||||||
IMG_INFO[img_src] = {width: image[:width], height: image[:height]}
|
IMG_INFO[img_src] = {width: image[:width], height: image[:height]}
|
||||||
|
@ -55,7 +56,6 @@ class PageContentsController < OrbitAdminController
|
||||||
if image[:height]
|
if image[:height]
|
||||||
metas << {"property" => "og:image:height", "content" => image[:height].to_s}
|
metas << {"property" => "og:image:height", "content" => image[:height].to_s}
|
||||||
end
|
end
|
||||||
image_file.close
|
|
||||||
image_file.unlink
|
image_file.unlink
|
||||||
rescue MiniMagick::Invalid => e
|
rescue MiniMagick::Invalid => e
|
||||||
puts ["src = #{img_src}", e.to_s]
|
puts ["src = #{img_src}", e.to_s]
|
||||||
|
|
Loading…
Reference in New Issue