wger icon indicating copy to clipboard operation
wger copied to clipboard

Automatic Date reading from image metadata in gallery

Open user12257 opened this issue 4 weeks ago • 8 comments

Use case

Hi,

when uploading older images to wger, it would be useful not to enter the date manually, but to have it read from the Metadata.

Proposal

Having the default date being set to the image metadata date. If the user adjusted the date manually before uploading an image it should not change.

Additional Context

No response

user12257 avatar Nov 30 '25 14:11 user12257

hi! You mean for the gallery? That's a good idea!

rolandgeider avatar Nov 30 '25 14:11 rolandgeider

Yes, exactly, I think it would be a relatively simple quality of life improvement. I am not familiar with the codebase, but would assume it would be a client feature. It could maybe also be a server feature, allowing the client to send an auto-calc flag, this might also allow for bulk uploads. Might be useful when first setting up the account.

user12257 avatar Nov 30 '25 14:11 user12257

I'd see this as a backend feature, if there's a date use that, otherwise try to read the metadata (and default to today if nothing could be extracted)

rolandgeider avatar Nov 30 '25 14:11 rolandgeider

I thought of it as a frontend Feature, bc the metadata might be wrong or missing and not be from today.

But as I think about it more, when it defaults to "today" the picture would show up as the newest one, and can easily be edited after uploading.

It would only be annoying if the user has many pictures already uploaded, has an image with wrong metadata and uploads it. The user would then have to go search for the picture and edit it. But that is probably an edgecase as most probably use their phone for pictures which have probably the correct time.

user12257 avatar Nov 30 '25 15:11 user12257

I could take a look at implementing this, although I am not familiar with such a python application. But this feature seems fairly straight forward.

user12257 avatar Nov 30 '25 16:11 user12257

Sure, go ahead!

rolandgeider avatar Dec 01 '25 08:12 rolandgeider

I have never used Django before, so forgive me if I am asking a stupid question.

But from what it looks like to me, and from what I read online I thought the perform_create method in the GalleryImageViewSet would be the place to intercept the post data.

But when I add some print statements there an upload a new image, I don't see anything. When I add an exit(1) nothing changes either, and when I just uncomment the function I can still upload images to the gallery without a problem.

Is this the wrong place to look?

user12257 avatar Dec 05 '25 17:12 user12257

there's no stupid questions!! (specially not with such a big system)

I took a look and the form you see when using the app is from wger/gallery/forms.py, the view set is used when accessing the API, like the mobile app does. For this kind of logic, you could either overwrite the save method in the image model, or add a pre_save signal

rolandgeider avatar Dec 05 '25 18:12 rolandgeider