diff --git a/app/controllers/page_contents_controller.rb b/app/controllers/page_contents_controller.rb index 62c6476..1b698bc 100644 --- a/app/controllers/page_contents_controller.rb +++ b/app/controllers/page_contents_controller.rb @@ -28,12 +28,15 @@ class PageContentsController < OrbitAdminController metas << {"property" => "og:image", "content" => URI.join(request.base_url, URI.encode(img_src)).to_s} if img_src.start_with?('/') img_src_path = File.join('public', img_src) - 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} + 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} + end end else res = get_response(URI.parse(img_src))