FIX: only add image size when with & height are in pixels

This commit is contained in:
Régis Hanol 2019-07-05 20:34:11 +02:00
parent 589351d996
commit 155cad8b85
2 changed files with 5 additions and 3 deletions

View File

@ -220,10 +220,10 @@ class InlineUploads
if src && (matched_uploads(src).present? || external_src) if src && (matched_uploads(src).present? || external_src)
text = node.attributes["alt"]&.value text = node.attributes["alt"]&.value
width = node.attributes["width"]&.value width = node.attributes["width"]&.value.to_i
height = node.attributes["height"]&.value height = node.attributes["height"]&.value.to_i
title = node.attributes["title"]&.value title = node.attributes["title"]&.value
text = "#{text}|#{width}x#{height}" if width && height text = "#{text}|#{width}x#{height}" if width > 0 && height > 0
after_html_tag = match[0].present? after_html_tag = match[0].present?
spaces_before = spaces_before =

View File

@ -267,6 +267,7 @@ RSpec.describe InlineUploads do
#{Discourse.base_url}#{upload3.url} #{Discourse.base_url}#{upload3.url} #{Discourse.base_url}#{upload3.url} #{Discourse.base_url}#{upload3.url}
<img src="#{upload.url}" width="5" height="4"> <img src="#{upload.url}" width="5" height="4">
<img src="#{upload.url}" width="5px" height="auto">
MD MD
expect(InlineUploads.process(md)).to eq(<<~MD) expect(InlineUploads.process(md)).to eq(<<~MD)
@ -283,6 +284,7 @@ RSpec.describe InlineUploads do
#{Discourse.base_url}#{upload3.short_path} #{Discourse.base_url}#{upload3.short_path} #{Discourse.base_url}#{upload3.short_path} #{Discourse.base_url}#{upload3.short_path}
![|5x4](#{upload.short_url}) ![|5x4](#{upload.short_url})
![](#{upload.short_url})
MD MD
end end