avatar

package
v0.0.0-...-5c0bb04 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserAvatarBrandType = "user-avatar"
	UserCoverBrandType  = "user-cover"
)

avatar brand type list

Variables

This section is empty.

Functions

func BrandPath

func BrandPath(brand Brandable, userID uint, filename string) string

BrandPath get image relative path

func BrandUrls

func BrandUrls(ctx echo.Context, brand Brandable, userID uint, filename string) map[string]string

BrandUrls get image urls by brand

func DeleteImage

func DeleteImage(brand Brandable, userID uint, filename string) error

DeleteImage delete image file

func DeleteUserAvatar

func DeleteUserAvatar(userID uint) (*database.User, error)

DeleteUserAvatar delete user avatar and reset to default avatar

func UploadImage

func UploadImage(brand Brandable, userID uint, mediaType string, reader io.Reader) (string, error)

UploadImage upload image and return a filename

Types

type Brandable

type Brandable interface {
	// e.g: user-avatar, user-cover, topic-cover
	BrandType() string

	// e.g:
	//
	// {
	//   'small': [width number, height number],
	//   'middle': [width number, height number],
	//   'large': [width number, height number]
	// }
	BrandSize() map[string][2]int

	// e.g: {'original': 'url', 'size string': 'url'}
	DefaultBrandUrls() map[string]string
}

Brandable object logo e.g: user-avatar, user-cover, topic-cover

type UserAvatar

type UserAvatar struct{}

UserAvatar impl avatar.Brandable for user avatar

func (*UserAvatar) BrandSize

func (u *UserAvatar) BrandSize() map[string][2]int

BrandSize user avatar size

func (*UserAvatar) BrandType

func (u *UserAvatar) BrandType() string

BrandType user avatar type

func (*UserAvatar) DefaultBrandUrls

func (u *UserAvatar) DefaultBrandUrls() map[string]string

DefaultBrandUrls default user avatar

type UserCover

type UserCover struct{}

UserCover impl avatar.Brandable for user cover

func (*UserCover) BrandSize

func (u *UserCover) BrandSize() map[string][2]int

BrandSize user cover size

func (*UserCover) BrandType

func (u *UserCover) BrandType() string

BrandType user cover type

func (*UserCover) DefaultBrandUrls

func (u *UserCover) DefaultBrandUrls() map[string]string

DefaultBrandUrls default user cover

Jump to

Keyboard shortcuts

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