media_library

package
v0.0.0-...-2898c89 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2015 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotImplemented = errors.New("not implemented")

Functions

func SaveAndCropImage

func SaveAndCropImage(isCreate bool) func(scope *gorm.Scope)

Types

type Base

type Base struct {
	FileName    string `sql:"size:10240"`
	Url         string
	CropOptions map[string]*CropOption `json:",omitempty"`
	Crop        bool                   `json:"-"`
	Valid       bool                   `json:"-"`
	FileHeader  fileHeader             `json:"-"`
	Reader      io.Reader              `json:"-"`
}

func (*Base) GetCropOption

func (b *Base) GetCropOption(name string) *image.Rectangle

func (Base) GetFileHeader

func (b Base) GetFileHeader() fileHeader

func (Base) GetFileName

func (b Base) GetFileName() string

func (Base) GetSizes

func (b Base) GetSizes() map[string]Size

func (Base) GetURL

func (b Base) GetURL(option *Option, scope *gorm.Scope, field *gorm.Field, templater URLTemplater) string

func (Base) GetURLTemplate

func (b Base) GetURLTemplate(option *Option) (path string)

func (Base) IsImage

func (b Base) IsImage() bool

func (*Base) NeedCrop

func (b *Base) NeedCrop() bool

func (Base) Retrieve

func (b Base) Retrieve(url string) (*os.File, error)

func (*Base) Scan

func (b *Base) Scan(data interface{}) (err error)

func (Base) String

func (b Base) String() string

func (Base) URL

func (b Base) URL(styles ...string) string

func (Base) Value

func (b Base) Value() (driver.Value, error)

type CropOption

type CropOption struct {
	X, Y, Width, Height int
}

type FileSystem

type FileSystem struct {
	Base
}

func (FileSystem) GetFullPath

func (f FileSystem) GetFullPath(url string, option *Option) (path string, err error)

func (FileSystem) Retrieve

func (f FileSystem) Retrieve(url string) (*os.File, error)

func (FileSystem) Store

func (f FileSystem) Store(url string, option *Option, reader io.Reader) error

type MediaLibrary

type MediaLibrary interface {
	Scan(value interface{}) error
	Value() (driver.Value, error)

	GetURLTemplate(*Option) string
	GetURL(option *Option, scope *gorm.Scope, field *gorm.Field, templater URLTemplater) string

	GetFileHeader() fileHeader
	GetFileName() string

	GetSizes() map[string]Size
	NeedCrop() bool
	GetCropOption(name string) *image.Rectangle

	Store(url string, option *Option, reader io.Reader) error
	Retrieve(url string) (*os.File, error)

	IsImage() bool

	URL(style ...string) string
	String() string
}

type Option

type Option map[string]string

func (Option) Get

func (option Option) Get(key string) string

type Size

type Size struct {
	Width  int
	Height int
}

type URLTemplater

type URLTemplater interface {
	GetURLTemplate(*Option) string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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