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 it "renders a figure and figure caption" do
page = Page.new(nodes: [ page = Page.new(nodes: [
Figure.new(children: [ Figure.new(children: [
Image.new(src: "image.png", originalWidth: 100, originalHeight: 100), Image.new(src: "image.png", originalWidth: 100, originalHeight: 200),
FigureCaption.new(children: [ FigureCaption.new(children: [
Text.new("A caption"), Text.new("A caption"),
] of Child), ] of Child),
@ -101,7 +101,7 @@ describe PageContent do
html.should eq stripped_html <<-HTML html.should eq stripped_html <<-HTML
<figure> <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> <figcaption>A caption</figcaption>
</figure> </figure>
HTML HTML
@ -134,7 +134,7 @@ describe PageContent do
it "renders an image" do it "renders an image" do
page = Page.new(nodes: [ page = Page.new(nodes: [
Paragraph.new(children: [ 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),
] of Child) ] of Child)
@ -142,7 +142,7 @@ describe PageContent do
html.should eq stripped_html <<-HTML html.should eq stripped_html <<-HTML
<p> <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> </p>
HTML HTML
end end

View file

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