Resolve imported thumbnail mappings
This commit is contained in:
1 parent
389dd8649d
commit
170a25188b
1 file changed
+11
@@ -200,6 +200,17 @@ func (c *Core) thumbnailMediaIdentifier(w http.ResponseWriter, r *http.Request,
|
||||
return
|
||||
}
|
||||
}
|
||||
var thumbnailID string
|
||||
if err := c.db.QueryRow(r.Context(), `
|
||||
SELECT t.id::text
|
||||
FROM thumbnails t
|
||||
JOIN media m ON m.id = t.media_id OR t.source_path = COALESCE(NULLIF(m.file_path, ''), m.media_key)
|
||||
WHERE m.media_key=$1 OR CAST(m.id AS TEXT)=$1
|
||||
ORDER BY t.created_at DESC
|
||||
LIMIT 1`, id).Scan(&thumbnailID); err == nil && SafeRelative(thumbnailID) {
|
||||
c.carrierNode.Proxy(w, r, "/thumbnails/"+thumbnailID+".jpg")
|
||||
return
|
||||
}
|
||||
record, err := c.findMedia(r.Context(), id)
|
||||
if err != nil || !isImagePath(record.FilePath) {
|
||||
writeError(w, http.StatusNotFound, "thumbnail not found")
|
||||
|
||||
Reference in new issue
Block a user