X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/7f3cb3c6246e6e271761e714cceb081e85a4d245..0472d7b0bc68fbf7b4179aa0f1be51a369562179:/lib/rich_text.rb diff --git a/lib/rich_text.rb b/lib/rich_text.rb index f19d3d3a9..edfa535f4 100644 --- a/lib/rich_text.rb +++ b/lib/rich_text.rb @@ -104,13 +104,17 @@ module RichText end def first_image_element(element) - return element if element.type == :img + return element if image?(element) && element.attr["src"].present? element.children.find do |child| nested_image = first_image_element(child) break nested_image if nested_image end end + + def image?(element) + element.type == :img || (element.type == :html_element && element.value == "img") + end end class Text < Base