Support null image widths and heights

This commit is contained in:
Edward Loveall 2021-11-06 13:22:03 -04:00
parent 4b354c659f
commit 027e59645d
No known key found for this signature in database
GPG key ID: 789A4AE983AC8901
2 changed files with 12 additions and 5 deletions

View file

@ -88,11 +88,18 @@ module Nodes
class Image class Image
IMAGE_HOST = "https://cdn-images-1.medium.com/fit/c" IMAGE_HOST = "https://cdn-images-1.medium.com/fit/c"
MAX_WIDTH = 800 MAX_WIDTH = 800
FALLBACK_HEIGHT = 600
getter originalHeight : Int32 getter originalHeight : Int32
getter originalWidth : Int32 getter originalWidth : Int32
def initialize(@src : String, @originalWidth : Int32, @originalHeight : Int32) def initialize(
@src : String,
originalWidth : Int32?,
originalHeight : Int32?
)
@originalWidth = originalWidth || MAX_WIDTH
@originalHeight = originalHeight || FALLBACK_HEIGHT
end end
def ==(other : Image) def ==(other : Image)

View file

@ -91,7 +91,7 @@ class PostResponse
class Metadata < Base class Metadata < Base
property id : String property id : String
property originalWidth : Int32 property originalWidth : Int32?
property originalHeight : Int32 property originalHeight : Int32?
end end
end end