mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02:00
Image resource refactor
This commit pulls most of the image related logic into its own package, to make it easier to reason about and extend. This is also a rewrite of the transformation logic used in Hugo Pipes, mostly to allow constructs like the one below: {{ ($myimg | fingerprint ).Width }} Fixes #5903 Fixes #6234 Fixes #6266
This commit is contained in:
@@ -23,7 +23,7 @@ import (
|
||||
// Cloner is an internal template and not meant for use in the templates. It
|
||||
// may change without notice.
|
||||
type Cloner interface {
|
||||
WithNewBase(base string) Resource
|
||||
Clone() Resource
|
||||
}
|
||||
|
||||
// Resource represents a linkable resource, i.e. a content page, image etc.
|
||||
@@ -35,6 +35,20 @@ type Resource interface {
|
||||
ResourceDataProvider
|
||||
}
|
||||
|
||||
// Image represents an image resource.
|
||||
type Image interface {
|
||||
Resource
|
||||
ImageOps
|
||||
}
|
||||
|
||||
type ImageOps interface {
|
||||
Height() int
|
||||
Width() int
|
||||
Fill(spec string) (Image, error)
|
||||
Fit(spec string) (Image, error)
|
||||
Resize(spec string) (Image, error)
|
||||
}
|
||||
|
||||
type ResourceTypesProvider interface {
|
||||
// MediaType is this resource's MIME type.
|
||||
MediaType() media.Type
|
||||
@@ -117,6 +131,10 @@ type OpenReadSeekCloser func() (hugio.ReadSeekCloser, error)
|
||||
// ReadSeekCloserResource is a Resource that supports loading its content.
|
||||
type ReadSeekCloserResource interface {
|
||||
MediaType() media.Type
|
||||
ReadSeekCloserProvider
|
||||
}
|
||||
|
||||
type ReadSeekCloserProvider interface {
|
||||
ReadSeekCloser() (hugio.ReadSeekCloser, error)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user