Fix error when image type not support by minimagick.
This commit is contained in:
parent
c0bd6253e2
commit
6e9c00464d
|
@ -46,16 +46,20 @@ 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 = MiniMagick::Image.open(image_file.path)
|
begin
|
||||||
IMG_INFO[img_src] = {width: image[:width], height: image[:height]}
|
image = MiniMagick::Image.open(image_file.path)
|
||||||
if image[:width]
|
IMG_INFO[img_src] = {width: image[:width], height: image[:height]}
|
||||||
metas << {"property" => "og:image:width", "content" => image[:width].to_s}
|
if image[:width]
|
||||||
|
metas << {"property" => "og:image:width", "content" => image[:width].to_s}
|
||||||
|
end
|
||||||
|
if image[:height]
|
||||||
|
metas << {"property" => "og:image:height", "content" => image[:height].to_s}
|
||||||
|
end
|
||||||
|
image_file.close
|
||||||
|
image_file.unlink
|
||||||
|
rescue MiniMagick::Invalid => e
|
||||||
|
puts ["src = #{img_src}", e.to_s]
|
||||||
end
|
end
|
||||||
if image[:height]
|
|
||||||
metas << {"property" => "og:image:height", "content" => image[:height].to_s}
|
|
||||||
end
|
|
||||||
image_file.close
|
|
||||||
image_file.unlink
|
|
||||||
else
|
else
|
||||||
IMG_INFO[img_src] = {}
|
IMG_INFO[img_src] = {}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue