contentfulvalidation/validations/asset.go
2023-08-30 17:44:17 +02:00

23 lines
463 B
Go

package validations
import (
"github.com/foomo/contentful"
"github.com/foomo/contentfulvalidation/utils"
)
func IsLandscapeRatio(asset *contentful.AssetNoLocale) bool {
aspectRatio, err := utils.GetAspectRatio(asset)
if err != nil {
return false
}
return aspectRatio >= 1.00
}
func IsPortraitRatio(asset *contentful.AssetNoLocale) bool {
aspectRatio, err := utils.GetAspectRatio(asset)
if err != nil {
return false
}
return aspectRatio <= 1.00
}