feat: image variants per image
This commit is contained in:
1 parent
f567866161
commit
951fef18ba
92 files changed
+8695
-413
No files matched your search
@@ -0,0 +1,33 @@
|
||||
package useCases
|
||||
|
||||
import "RenewCMS/internal/domain/image"
|
||||
|
||||
type ListImageVariantsUseCase struct {
|
||||
images image.Repository
|
||||
variants image.VariantRepository
|
||||
files image.VariantFileRepository
|
||||
renderer image.VariantRenderer
|
||||
}
|
||||
|
||||
func NewListImageVariantsUseCase(images image.Repository, variants image.VariantRepository, files image.VariantFileRepository, renderer image.VariantRenderer) *ListImageVariantsUseCase {
|
||||
return &ListImageVariantsUseCase{images, variants, files, renderer}
|
||||
}
|
||||
|
||||
func (u *ListImageVariantsUseCase) List(id uint32) (ImageVariantList, error) {
|
||||
img, err := u.images.Get(id)
|
||||
if err != nil {
|
||||
return ImageVariantList{}, err
|
||||
}
|
||||
if isVectorSource(img) {
|
||||
return ImageVariantList{Unsupported: unsupportedSVG, Items: []ImageVariantView{}}, nil
|
||||
}
|
||||
enabled, err := enabledVariants(u.variants)
|
||||
if err != nil {
|
||||
return ImageVariantList{}, err
|
||||
}
|
||||
rows, err := currentFiles(u.files, image.StoredName(img.Path))
|
||||
if err != nil {
|
||||
return ImageVariantList{}, err
|
||||
}
|
||||
return ImageVariantList{Items: viewsOf(enabled, img, rows, u.renderer.EncodableFormats())}, nil
|
||||
}
|
||||
Reference in new issue
Block a user