-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Vincent Boutour <[email protected]>
- Loading branch information
Showing
5 changed files
with
61 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package crud | ||
|
||
import ( | ||
"context" | ||
|
||
absto "github.com/ViBiOh/absto/pkg/model" | ||
"github.com/ViBiOh/fibr/pkg/provider" | ||
"github.com/ViBiOh/fibr/pkg/thumbnail" | ||
) | ||
|
||
type cover struct { | ||
Img provider.RenderItem | ||
ImgHeight uint64 | ||
ImgWidth uint64 | ||
} | ||
|
||
func newCover(item provider.RenderItem, size uint64) cover { | ||
return cover{ | ||
Img: item, | ||
ImgHeight: size, | ||
ImgWidth: size, | ||
} | ||
} | ||
|
||
func (c cover) IsZero() bool { | ||
return len(c.Img.Item.Name) == 0 | ||
} | ||
|
||
func (a App) getCover(ctx context.Context, request provider.Request, files []absto.Item) (output cover) { | ||
for _, file := range files { | ||
if a.thumbnailApp.HasThumbnail(ctx, file, thumbnail.SmallSize) { | ||
output = newCover(provider.StorageToRender(file, request), thumbnail.SmallSize) | ||
return | ||
} | ||
} | ||
|
||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters