diff --git a/common-lib/src/main/scala/com/gu/mediaservice/model/Asset.scala b/common-lib/src/main/scala/com/gu/mediaservice/model/Asset.scala index 0fba94caae..8e996309a3 100644 --- a/common-lib/src/main/scala/com/gu/mediaservice/model/Asset.scala +++ b/common-lib/src/main/scala/com/gu/mediaservice/model/Asset.scala @@ -27,13 +27,25 @@ object Asset { orientationMetadata.correctedDimensions(dimensions) } - val orientation = for { + val maybeCorrectedOrientation = for { dimensions <- dims orientationMetadata <- orientationMetadata } yield { orientationMetadata.correctedOrientation(dimensions) } + val maybeDimensionsOrientation = for { + dimensions <- dims + } yield { + if (dimensions.width < dimensions.height) { + "portrait" + } else { + "landscape" + } + } + + val maybeOrientation = Seq(maybeCorrectedOrientation, maybeDimensionsOrientation).flatten.headOption + Asset( file = s3Object.uri, size = Some(s3Object.size), @@ -42,7 +54,7 @@ object Asset { secureUrl = None, orientationMetadata = orientationMetadata, orientedDimensions = orientedDimensions, - orientation = orientation + orientation = maybeOrientation ) }