Fix img src not decode.
This commit is contained in:
parent
9056303b5d
commit
c0bd6253e2
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue