Don't render image heights explicitly

The CSS itself will take care of scaling the image height based on the
width. We still need to know the height to fetch the image because the
height is in the URL, but we don't need to render it in the HTML.
This commit is contained in:
Edward Loveall 2021-08-14 16:07:31 -04:00
parent bf43c7f467
commit 5c05086cbd
No known key found for this signature in database
GPG Key ID: 789A4AE983AC8901
2 changed files with 5 additions and 5 deletions

View File

@ -90,7 +90,7 @@ describe PageContent do
it "renders a figure and figure caption" do
page = Page.new(nodes: [
Figure.new(children: [
Image.new(src: "image.png", originalWidth: 100, originalHeight: 100),
Image.new(src: "image.png", originalWidth: 100, originalHeight: 200),
FigureCaption.new(children: [
Text.new("A caption"),
] of Child),
@ -101,7 +101,7 @@ describe PageContent do
html.should eq stripped_html <<-HTML
<figure>
<img src="https://cdn-images-1.medium.com/fit/c/100/100/image.png" width="100" height="100">
<img src="https://cdn-images-1.medium.com/fit/c/100/200/image.png" width="100">
<figcaption>A caption</figcaption>
</figure>
HTML
@ -134,7 +134,7 @@ describe PageContent do
it "renders an image" do
page = Page.new(nodes: [
Paragraph.new(children: [
Image.new(src: "image.png", originalWidth: 100, originalHeight: 100),
Image.new(src: "image.png", originalWidth: 100, originalHeight: 200),
] of Child),
] of Child)
@ -142,7 +142,7 @@ describe PageContent do
html.should eq stripped_html <<-HTML
<p>
<img src="https://cdn-images-1.medium.com/fit/c/100/100/image.png" width="100" height="100">
<img src="https://cdn-images-1.medium.com/fit/c/100/200/image.png" width="100">
</p>
HTML
end

View File

@ -63,7 +63,7 @@ class PageContent < BaseComponent
end
def render_child(child : Image)
img src: child.src, width: child.width, height: child.height
img src: child.src, width: child.width
end
def render_child(node : ListItem)