mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 09:22:42 +08:00
FIX: Use basic meta description if other description tags are missing (#15356)
When attempting to Onebox a page if there is no `meta property="og:description"` tag but there is a `meta name="description"` tag, Onebox should try to use that value.
This commit is contained in:
@ -58,7 +58,12 @@ module Onebox
|
||||
end
|
||||
|
||||
favicon = get_favicon
|
||||
@raw["favicon".to_sym] = favicon unless Onebox::Helpers::blank?(favicon)
|
||||
@raw[:favicon] = favicon unless Onebox::Helpers::blank?(favicon)
|
||||
|
||||
unless @raw[:description]
|
||||
description = get_description
|
||||
@raw[:description] = description unless Onebox::Helpers::blank?(description)
|
||||
end
|
||||
|
||||
@raw
|
||||
end
|
||||
@ -106,6 +111,15 @@ module Onebox
|
||||
Onebox::Helpers::get_absolute_image_url(favicon, url)
|
||||
end
|
||||
|
||||
def get_description
|
||||
return nil unless html_doc
|
||||
|
||||
description = html_doc.at("meta[name='description']").to_h['content']
|
||||
description ||= html_doc.at("meta[name='Description']").to_h['content']
|
||||
|
||||
description
|
||||
end
|
||||
|
||||
def get_json_response
|
||||
oembed_url = get_oembed_url
|
||||
|
||||
|
Reference in New Issue
Block a user