mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-09-26 19:46:43 +02:00
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package auximageprovider
|
|
|
|
import (
|
|
"github.com/imgproxy/imgproxy/v3/config"
|
|
"github.com/imgproxy/imgproxy/v3/ensure"
|
|
)
|
|
|
|
// StaticConfig holds the configuration for the auxiliary image provider
|
|
type StaticConfig struct {
|
|
Base64Data string
|
|
Path string
|
|
URL string
|
|
}
|
|
|
|
// NewDefaultStaticConfig creates a new default configuration for the auxiliary image provider
|
|
func NewDefaultStaticConfig() StaticConfig {
|
|
return StaticConfig{
|
|
Base64Data: "",
|
|
Path: "",
|
|
URL: "",
|
|
}
|
|
}
|
|
|
|
// LoadWatermarkStaticConfigFromEnv loads the watermark configuration from the environment
|
|
func LoadWatermarkStaticConfigFromEnv(c *StaticConfig) (*StaticConfig, error) {
|
|
c = ensure.Ensure(c, NewDefaultStaticConfig)
|
|
|
|
c.Base64Data = config.WatermarkData
|
|
c.Path = config.WatermarkPath
|
|
c.URL = config.WatermarkURL
|
|
|
|
return c, nil
|
|
}
|
|
|
|
// LoadFallbackStaticConfigFromEnv loads the fallback configuration from the environment
|
|
func LoadFallbackStaticConfigFromEnv(c *StaticConfig) (*StaticConfig, error) {
|
|
c = ensure.Ensure(c, NewDefaultStaticConfig)
|
|
|
|
c.Base64Data = config.FallbackImageData
|
|
c.Path = config.FallbackImagePath
|
|
c.URL = config.FallbackImageURL
|
|
|
|
return c, nil
|
|
}
|