photoprism/pkg/media/filename.go
Michael Mayer 604849e92c Search: Include RAW files in results by default #2040
With these changes the size and type of the RAW file as well as other
details can be displayed in the Cards View. This also improves the
indexing of camera and lens metadata.

Signed-off-by: Michael Mayer <michael@photoprism.app>
2023-10-06 02:22:48 +02:00

26 lines
525 B
Go

package media
import (
"github.com/photoprism/photoprism/pkg/fs"
)
// FromName returns the content type matching the file extension.
func FromName(fileName string) Type {
if fileName == "" {
return Unknown
}
// Find media type based on the file type.
if result, found := Formats[fs.FileType(fileName)]; found {
return result
}
// Default to sidecar.
return Sidecar
}
// MainFile checks if the filename belongs to a main content type.
func MainFile(fileName string) bool {
return FromName(fileName).Main()
}