From 5c05086cbdd49df35c3084a25c0db24a3847277c Mon Sep 17 00:00:00 2001 From: Edward Loveall Date: Sat, 14 Aug 2021 16:07:31 -0400 Subject: [PATCH] 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. --- spec/components/page_content_spec.cr | 8 ++++---- src/components/page_content.cr | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/components/page_content_spec.cr b/spec/components/page_content_spec.cr index fdb07bb..4d1d3c7 100644 --- a/spec/components/page_content_spec.cr +++ b/spec/components/page_content_spec.cr @@ -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
- +
A caption
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

- +

HTML end diff --git a/src/components/page_content.cr b/src/components/page_content.cr index 9ccf7cd..55dda5f 100644 --- a/src/components/page_content.cr +++ b/src/components/page_content.cr @@ -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)