~edwardloveall/scribe

027e59645dd37e762b6e4430639e7ab0966ac2f1 — Edward Loveall 6 months ago 4b354c6
Support null image widths and heights
2 files changed, 12 insertions(+), 5 deletions(-)

M src/models/nodes.cr
M src/models/post_response.cr
M src/models/nodes.cr => src/models/nodes.cr +10 -3
@@ 86,13 86,20 @@ module Nodes
  end

  class Image
    IMAGE_HOST = "https://cdn-images-1.medium.com/fit/c"
    MAX_WIDTH  = 800
    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)

M src/models/post_response.cr => src/models/post_response.cr +2 -2
@@ 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