fix svg file cannot open error, just skip get width or height

This commit is contained in:
chiu 2024-10-04 06:51:10 +00:00
parent f682f99975
commit 8850d99824
1 changed files with 8 additions and 6 deletions

View File

@ -30,12 +30,14 @@ class PageContentsController < OrbitAdminController
img_src_path = File.join('public', img_src)
img_src_path = URI.decode(img_src_path)
if File.exist?(img_src_path)
image = MiniMagick::Image.open(img_src_path)
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}
image = MiniMagick::Image.open(img_src_path) rescue nil
if image
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
end
end
else