Documentation ¶
Index ¶
- Constants
- Variables
- func GetImageStyle(ctx *core.Context) string
- func IgnoreCallback(db *aorm.DB) *aorm.DB
- func ImageMetaGetDefaultURL(meta *admin.Meta, recorde interface{}, ctx *core.Context) (url string)
- func ImageMetaOnDefaultValue(meta *admin.Meta, cb func(e *admin.MetaValuerEvent))
- func ImageMetaURL(meta *admin.Meta, key, defaultStyle string) *admin.Meta
- func IsIgnoreCallback(v interface{}) bool
- func RegisterCallbacks(db *aorm.DB)
- type CropOption
- type CropperOption
- type Doc
- type Image
- func (img *Image) ConfigureQorMetaBeforeInitialize(meta resource.Metaor)
- func (img *Image) ContextScan(ctx *core.Context, data interface{}) (err error)
- func (img Image) Cropable() bool
- func (img *Image) Cropped(values ...bool) (result bool)
- func (img Image) Export(ctx *core.Context) (string, error)
- func (Image) FileExts() []string
- func (Image) FileTypes() []string
- func (img *Image) GetCropOption(name string) *CropOption
- func (img *Image) GetCropOptions() map[string]*CropOption
- func (img *Image) GetOriginalSize() *Size
- func (img Image) GetSizes() map[string]*Size
- func (img Image) HasImage() bool
- func (img *Image) Init(site *core.Site, field *aorm.Field)
- func (Image) MaxSize() uint64
- func (img *Image) MediaScan(ctx *media.Context, data interface{}) (err error)
- func (img *Image) NeedCrop() bool
- func (img Image) OriginalSizeDefined() bool
- func (img *Image) Scan(data interface{}) (err error)
- func (img *Image) ScanBytes(ctx *media.Context, data []byte) (err error)
- func (img *Image) Set(ctx *media.Context, data interface{}) (err error)
- func (img Image) SystemNames() []string
- func (img Image) Value() (driver.Value, error)
- type ImageCropper
- func (cropper *ImageCropper) Crop(options map[string]*CropperOption, cb func(key string, f *bytes.Buffer) error) (err error)
- func (cropper *ImageCropper) CropNames(cb func(key string, f *bytes.Buffer) error, names ...string) (err error)
- func (cropper *ImageCropper) Height() (w int)
- func (cropper *ImageCropper) Size() (w int, h int)
- func (cropper *ImageCropper) Width() (w int)
- type ImageInterface
- type ImageMeta
- func (this *ImageMeta) ConfigureQorMeta(metaor resource.Metaor)
- func (this *ImageMeta) DefaultURL(ctx *core.Context, record interface{}, value *Image) string
- func (this *ImageMeta) GetURL(ctx *core.Context, record interface{}, value *Image) (url string)
- func (this *ImageMeta) StyleURL(ctx *core.Context, record interface{}, style ...string) (url string)
- type ImageOrLink
- type ImageOrLinkOrVideoLink
- type ImageOrVideoType
- type ImageOrVideoWithLink
- type ImageWithLink
- type MediaType
- type OSS
- func (o *OSS) ContextScan(ctx *core.Context, data interface{}) (err error)
- func (o *OSS) Init(site *core.Site, field *aorm.Field)
- func (o OSS) IsNew() bool
- func (o *OSS) MediaScan(ctx *media.Context, data interface{}) (err error)
- func (o *OSS) Remove(path string) (found bool, err error)
- func (o *OSS) Retrieve(path string) (*os.File, error)
- func (o *OSS) Scan(data interface{}) (err error)
- func (o *OSS) Set(ctx *media.Context, data interface{}) (err error)
- func (o *OSS) Store(path string, reader io.Reader) error
- type OSSInterface
- type Plugin
- type Size
- type Video
Constants ¶
View Source
const ( IMAGE_STYLE_PREVIEW = "@qor_preview" IMAGE_STYLE_ORIGNAL = "original" )
Variables ¶
View Source
var ( // Storage the storage used to save medias FileSystemStorage = filesystem.New(&filesystem.Config{RootDir: "./data"}) PKG = path_helpers.GetCalledDir() )
View Source
var DB_CALLBACK_IGNORE = PKG + ".callback.ignore"
View Source
var DefaultRemoveHandler = func(storage oss.StorageInterface, path string, option *media.Option) error {
return storage.Delete(path)
}
DefaultRemoveHandler used to store reader with default Storage
View Source
var DefaultRetrieveHandler = func(storage oss.StorageInterface, option *media.Option, path string) (*os.File, error) {
return storage.Get(path)
}
DefaultRetrieveHandler used to retrieve file
View Source
var DefaultStoreHandler = func(storage oss.StorageInterface, path string, option *media.Option, reader io.Reader) error {
_, err := storage.Put(path, reader)
return err
}
DefaultStoreHandler used to store reader with default Storage
View Source
var E_DEFAULT_IMAGE_URL = PKG + ".defaultImageURL"
View Source
var E_SAVE_AND_CROP = PKG + ":save_and_crop"
View Source
var KEY_ICON_STYLE = PKG + ".iconStyle"
View Source
var META_PREVIEW = PKG + ".preview"
Functions ¶
func GetImageStyle ¶
func ImageMetaGetDefaultURL ¶
func ImageMetaOnDefaultValue ¶
func ImageMetaOnDefaultValue(meta *admin.Meta, cb func(e *admin.MetaValuerEvent))
func IsIgnoreCallback ¶
func IsIgnoreCallback(v interface{}) bool
func RegisterCallbacks ¶
RegisterCallbacks register callback into GORM DB
Types ¶
type CropOption ¶
type CropOption struct {
X, Y, Width, Height int
}
CropOption includes crop options
func (CropOption) Rectangle ¶
func (cropOption CropOption) Rectangle() *image.Rectangle
type CropperOption ¶
type CropperOption struct { Size *Size Crop *CropOption }
type Doc ¶
type Doc struct {
OSS
}
func (*Doc) ConfigureQorMetaBeforeInitialize ¶
func (*Doc) ContextScan ¶
type Image ¶
type Image struct { OSS CropOptions map[string]*CropOption `json:",omitempty"` Crop bool `json:"-"` Sizes map[string]*Size `json:",omitempty"` OriginalSize Size // contains filtered or unexported fields }
func (*Image) ConfigureQorMetaBeforeInitialize ¶
func (*Image) ContextScan ¶
func (*Image) GetCropOption ¶
func (img *Image) GetCropOption(name string) *CropOption
GetCropOption get crop options
func (*Image) GetCropOptions ¶
func (img *Image) GetCropOptions() map[string]*CropOption
func (*Image) GetOriginalSize ¶
func (Image) OriginalSizeDefined ¶
func (Image) SystemNames ¶
type ImageCropper ¶
type ImageCropper struct { Image ImageInterface Img image.Image Format imaging.Format // contains filtered or unexported fields }
func NewImageCropper ¶
func NewImageCropper(img ImageInterface, file io.ReadSeeker) (cropper *ImageCropper, err error)
func (*ImageCropper) Crop ¶
func (cropper *ImageCropper) Crop(options map[string]*CropperOption, cb func(key string, f *bytes.Buffer) error) (err error)
func (*ImageCropper) Height ¶
func (cropper *ImageCropper) Height() (w int)
func (*ImageCropper) Size ¶
func (cropper *ImageCropper) Size() (w int, h int)
func (*ImageCropper) Width ¶
func (cropper *ImageCropper) Width() (w int)
type ImageInterface ¶
type ImageInterface interface { OSSInterface GetSizes() map[string]*Size NeedCrop() bool Cropped(values ...bool) bool GetCropOption(name string) *CropOption GetCropOptions() map[string]*CropOption GetOriginalSize() *Size OriginalSizeDefined() bool Cropable() bool }
type ImageMeta ¶
type ImageMeta struct { FormattedStyle string URLFunc func(meta *admin.Meta, ctx *core.Context, record interface{}, value *Image) string SvgDisabled bool // contains filtered or unexported fields }
func (*ImageMeta) ConfigureQorMeta ¶
func (*ImageMeta) DefaultURL ¶
type ImageOrLink ¶
type ImageOrLink struct { MediaType MediaType `sql:"type:varchar(24)"` ImageFile Image ImageWithLink }
func (*ImageOrLink) HasImageFile ¶
func (i *ImageOrLink) HasImageFile() bool
func (*ImageOrLink) ImageURLProvider ¶
func (i *ImageOrLink) ImageURLProvider() reader_provider.MediaReaderProvider
func (*ImageOrLink) IsImageFile ¶
func (i *ImageOrLink) IsImageFile(has ...bool) bool
func (*ImageOrLink) IsImageLink ¶
func (i *ImageOrLink) IsImageLink(has ...bool) bool
type ImageOrLinkOrVideoLink ¶
type ImageOrLinkOrVideoLink struct { ImageOrLink VideoLink string }
func (*ImageOrLinkOrVideoLink) HasVideoLink ¶
func (iv *ImageOrLinkOrVideoLink) HasVideoLink() bool
func (*ImageOrLinkOrVideoLink) IsVideoLink ¶
func (iv *ImageOrLinkOrVideoLink) IsVideoLink(has ...bool) bool
func (*ImageOrLinkOrVideoLink) VideoLinkProvider ¶
func (iv *ImageOrLinkOrVideoLink) VideoLinkProvider() reader_provider.MediaReaderProvider
type ImageOrVideoType ¶
type ImageOrVideoType string
type ImageOrVideoWithLink ¶
type ImageOrVideoWithLink struct { ImageOrLinkOrVideoLink VideoFile Video }
func (*ImageOrVideoWithLink) HasVideoFile ¶
func (iv *ImageOrVideoWithLink) HasVideoFile() bool
func (*ImageOrVideoWithLink) IsVideoFile ¶
func (iv *ImageOrVideoWithLink) IsVideoFile() bool
type ImageWithLink ¶
type ImageWithLink struct {
ImageLink string
}
func (*ImageWithLink) HasImageLink ¶
func (i *ImageWithLink) HasImageLink() bool
type OSS ¶
OSS common storage interface
func (*OSS) ContextScan ¶
type OSSInterface ¶
type Plugin ¶
type Plugin struct { db.DBNames plug.EventDispatcher SetupConfigKey string }
func (*Plugin) OnRegister ¶
func (p *Plugin) OnRegister()
func (*Plugin) RequireOptions ¶
Click to show internal directories.
Click to hide internal directories.