thumbnail

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidMaxWidth is returned when max_width is not a positive integer.
	ErrInvalidMaxWidth = errors.New("max_width must be an integer greater than 0")
	// ErrInvalidSuffix is returned when suffix is empty or does not start with '_'.
	ErrInvalidSuffix = errors.New("suffix must be non-empty and start with '_'")
	// ErrDuplicateSuffix is returned when suffix is duplicated across config entries.
	ErrDuplicateSuffix = errors.New("suffix must be unique across all thumbnail entries")
	// ErrSuffixNotFound is returned when no thumbnail config matches the given suffix.
	ErrSuffixNotFound = errors.New("thumbnail config not found for suffix")
)

Functions

func ValidateUnique

func ValidateUnique(configs []ThumbnailConfig) error

ValidateUnique checks configs for duplicate suffixes.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service caches thumbnail configurations and provides thread-safe access.

func NewService

func NewService() *Service

NewService creates a Service pre-loaded with default thumbnail config.

func (*Service) GetAll

func (s *Service) GetAll() []ThumbnailConfig

GetAll returns all cached thumbnail configs.

func (*Service) GetBySuffix

func (s *Service) GetBySuffix(suffix string) (ThumbnailConfig, error)

GetBySuffix returns the thumbnail config matching the given suffix.

func (*Service) LoadConfigFromFile

func (s *Service) LoadConfigFromFile(path string) error

LoadConfigFromFile reads a TOML file and loads thumbnail configs into the service. If the file does not exist, defaults (already cached) are kept and no error is returned.

type ThumbnailConfig

type ThumbnailConfig struct {
	MaxWidth int    `toml:"max_width"`
	Suffix   string `toml:"suffix"`
}

ThumbnailConfig represents a single thumbnail size configuration.

func (ThumbnailConfig) Validate

func (tc ThumbnailConfig) Validate() error

Validate checks the ThumbnailConfig fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL