]> git.openstreetmap.org Git - rails.git/blobdiff - lib/rich_text.rb
Lock note during status update to avoid race condition
[rails.git] / lib / rich_text.rb
index f19d3d3a952ddd2c8240e2ea8da228c434523ffc..edfa535f434c07d23fb88412ad9dd673c38645d5 100644 (file)
@@ -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