Skip to content

Avoid removing reference to artwork for tracks without the album tag#1607

Open
Zapdatt wants to merge 5 commits into
LMS-Community:public/9.2from
Zapdatt:disable-default-artwork-without-album-tag
Open

Avoid removing reference to artwork for tracks without the album tag#1607
Zapdatt wants to merge 5 commits into
LMS-Community:public/9.2from
Zapdatt:disable-default-artwork-without-album-tag

Conversation

@Zapdatt

@Zapdatt Zapdatt commented Jul 7, 2026

Copy link
Copy Markdown

Adds a server setting to preserve existing embedded artwork when tracks do not have a valid album tag, rather than always clearing artwork references and thereby defaulting to album artwork 0.

Previously, during scanning, LMS would clear artwork references when a track had no album. This option allows users to keep track-level embedded artwork instead.

Default behavior remains unchanged.

I added the setting in "Performance" because there is another setting there in regards to album artwork caching. It can be moved elsewhere if a more appropriate location is preferred.

This is very useful for someone like me who has lots of songs with embedded artwork, but without an album tag and does not want to change the default tags. Here is my thread on the forums so please take a look for context. https://forums.lyrion.org/forum/user-forums/logitech-media-server/1828045-no-artwork-for-individual-songs-bug?view=thread

@Zapdatt

Zapdatt commented Jul 7, 2026

Copy link
Copy Markdown
Author

This is my first time committing to a public repo so excuse me if I did anything wrong.

@Zapdatt Zapdatt changed the title Disable default artwork without album tag Setting to disable default artwork on tracks without the album tag Jul 7, 2026
Zapdatt added 4 commits July 7, 2026 21:12
title

Signed-off-by: Zapdatt <54618617+Zapdatt@users.noreply.github.com>
Signed-off-by: Zapdatt <54618617+Zapdatt@users.noreply.github.com>
Signed-off-by: Zapdatt <54618617+Zapdatt@users.noreply.github.com>
Added new settings for artwork preservation and descriptions.

Signed-off-by: Zapdatt <54618617+Zapdatt@users.noreply.github.com>
@Zapdatt Zapdatt force-pushed the disable-default-artwork-without-album-tag branch from bbb6486 to 4d7a624 Compare July 7, 2026 19:13
@michaelherger

Copy link
Copy Markdown
Member

Thanks for this PR! I'm wondering whether this really needs a new preference, or whether the current behaviour shouldn't be considered a bug. Would you mind investigating whether this could be changed to not delete the value if it existed, and if the album didn't exist before either?

@Zapdatt

Zapdatt commented Jul 8, 2026

Copy link
Copy Markdown
Author

@michaelherger
I took a look at it.
It probably isn't a bug, but my scenario of art + no album tag was not taken into consideration.
I'm pretty sure the intention of this code was to clear the artwork if an album used to have it but were to lose it, but in a case like mine when there never was an album cover, it ended up just clearing it anyways.
Though an artwork suddenly disappearing feels like a very niche case too, haha

After quit a bit of testing I found that changing the line elsif ( !$newCoverId ) { to elsif (!$newCoverId && $coverid && $albumid) { gives the desired results for all cases!
In my case of a track without album it will not remove the artwork.
If there is new artwork, it is still added without issue.
If the existing artwork has been removed, it will go back to default.

…ared,

Signed-off-by: Zapdatt <54618617+Zapdatt@users.noreply.github.com>
@Zapdatt

Zapdatt commented Jul 8, 2026

Copy link
Copy Markdown
Author

I have reverted the new preference I added, and updated my branch with the new working fix.

@Zapdatt Zapdatt changed the title Setting to disable default artwork on tracks without the album tag Avoid removing reference to artwork for tracks without the album tag Jul 8, 2026
@michaelherger

michaelherger commented Jul 8, 2026

Copy link
Copy Markdown
Member

I'm a bit puzzled. Maybe we should try to understand why we'd end up with no $newCoverId, but a $cover, as there's this comment a few lines up:

# check for new artwork to unchanged file
# - !$cover: there wasn't any previously
# - !$newCoverId: existing file has disappeared

Why would this fail, as $newCoverId would be calculated from $cover? Can you trace how this is failing in generateImageId() around line 407?

@Zapdatt

Zapdatt commented Jul 8, 2026

Copy link
Copy Markdown
Author

I'm not sure if I fully understand, but I tried logging the variables when removing around line 341, and also in generateImageId at line 407.
It seems like the cleanup happens before generateCoverId().
For albums without artwork $cover is 0 and generateImageId() is never performed, so $newCoverId is still undefined. Before my change the cleanup logic would treat any missing $newCoverId as if artwork had disappeared, but that would also catch albums that never had artwork (including no album). Adding my additional checks makes the distinction between if the album artwork actually disappearing or if no album artwork ever existed.

@michaelherger

Copy link
Copy Markdown
Member

In order to reproduce the issue would I have to touch such a file before a rescan, or would a simple rescan without changing the file be good enough?

Basically: can you give me step-by-step instructions how to reproduce this issue'

@Zapdatt

Zapdatt commented Jul 8, 2026

Copy link
Copy Markdown
Author

If you just add a track without the album tag that has embedded artwork and then scan it will be added but you won't see the artwork.
(Note that if the artwork is not embedded, but just laying in any folder that has a track without album tag, it will remain but also assigned to all tracks without the album tag.)

What I did was put a few of these tracks in a playlist, and doing "clear library and rescan everything", once finished I do "only rescan playlist". Then by repeatedly entering and exiting the playlist I if I enter it after they have been added, but before the clean up is done I was able to see the artwork, but when the entire process finishes they will all have been given the default artwork.

Also if you add the album tag to one of these tracks, you will see that repeating the procedure will result in the track keeping it's artwork even after everything is finished. This confirms that the issue is specifically for tracks without the album tag.

@Zapdatt

Zapdatt commented Jul 8, 2026

Copy link
Copy Markdown
Author

Here's a 2 min video https://youtu.be/coEiRDYg08A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants