Metadata: Simplify keyword indexing #920
This commit is contained in:
parent
899419383a
commit
378dd0812e
2 changed files with 14 additions and 9 deletions
|
@ -668,21 +668,24 @@ func (m *Photo) SaveDetails() error {
|
|||
|
||||
// FileTitle returns a photo title based on the file name and/or path.
|
||||
func (m *Photo) FileTitle() string {
|
||||
// Generate title based on photo name, if not generated:
|
||||
if !fs.IsGenerated(m.PhotoName) {
|
||||
if title := txt.FileTitle(m.PhotoName); title != "" {
|
||||
return title
|
||||
}
|
||||
}
|
||||
|
||||
if m.OriginalName != "" && !fs.IsGenerated(m.OriginalName) {
|
||||
if title := txt.FileTitle(m.OriginalName); title != "" {
|
||||
// Generate title based on original file name, if any:
|
||||
if m.OriginalName != "" {
|
||||
if title := txt.FileTitle(m.OriginalName); !fs.IsGenerated(m.OriginalName) && title != "" {
|
||||
return title
|
||||
} else if title := txt.FileTitle(path.Dir(m.OriginalName)); title != "" {
|
||||
} else if title := txt.FileTitle(filepath.Dir(m.OriginalName)); title != "" {
|
||||
return title
|
||||
}
|
||||
}
|
||||
|
||||
if m.PhotoPath != "" {
|
||||
// Generate title based on photo path, if any:
|
||||
if m.PhotoPath != "" && !fs.IsGenerated(m.PhotoPath) {
|
||||
return txt.FileTitle(m.PhotoPath)
|
||||
}
|
||||
|
||||
|
|
|
@ -277,8 +277,8 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) (
|
|||
file.OriginalName = originalName
|
||||
}
|
||||
|
||||
// Set photo original name based on file original name if empty.
|
||||
if photo.OriginalName == "" && file.OriginalName != "" {
|
||||
// Set photo original name based on file original name.
|
||||
if file.OriginalName != "" {
|
||||
photo.OriginalName = fs.StripKnownExt(file.OriginalName)
|
||||
}
|
||||
|
||||
|
@ -682,9 +682,11 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) (
|
|||
w = append(w, txt.FilenameKeywords(fileBase)...)
|
||||
}
|
||||
|
||||
if file.OriginalName != "" && !fs.IsGenerated(file.OriginalName) {
|
||||
w = append(w, txt.FilenameKeywords(file.OriginalName)...)
|
||||
} else if photo.OriginalName != "" && !fs.IsGenerated(photo.OriginalName) {
|
||||
if photo.OriginalName == "" {
|
||||
// Do nothing.
|
||||
} else if fs.IsGenerated(photo.OriginalName) {
|
||||
w = append(w, txt.FilenameKeywords(filepath.Dir(photo.OriginalName))...)
|
||||
} else {
|
||||
w = append(w, txt.FilenameKeywords(photo.OriginalName)...)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue