Support null image widths and heights
This commit is contained in:
parent
4b354c659f
commit
027e59645d
2 changed files with 12 additions and 5 deletions
|
@ -88,11 +88,18 @@ module Nodes
|
|||
class Image
|
||||
IMAGE_HOST = "https://cdn-images-1.medium.com/fit/c"
|
||||
MAX_WIDTH = 800
|
||||
FALLBACK_HEIGHT = 600
|
||||
|
||||
getter originalHeight : 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
|
||||
|
||||
def ==(other : Image)
|
||||
|
|
|
@ -91,7 +91,7 @@ class PostResponse
|
|||
|
||||
class Metadata < Base
|
||||
property id : String
|
||||
property originalWidth : Int32
|
||||
property originalHeight : Int32
|
||||
property originalWidth : Int32?
|
||||
property originalHeight : Int32?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue