X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/c7353c9ac1553b5fd4b26253ead0f129ca714717..5b707ae5ea3cd7397d723a9059d3fdcfebb88397:/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