Support null image widths and heights
This commit is contained in:
parent
4b354c659f
commit
027e59645d
2 changed files with 12 additions and 5 deletions
|
@ -86,13 +86,20 @@ module Nodes
|
||||||
end
|
end
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue