I have a web site that primarily show pictures. I'd like to use the actual date the picture was taken, not the create date in Umbraco. This is especially true when I go on a trip and don't load the pictures into Umbraco until I return.
This question has two parts, hopefully the same answer.
I would prefer to do this as a field within Umbraco, not at render time.
The first case is to go through all of the existing pictures and extract the date the picture was taken and upload the item in Umbraco.
The second case is to extract the date the picture was taken when new pictures are uploaded.
I don't believe there is such a plugin available yet (I looked). Would someone be able to point me in the right direction?
to give editors ability to choose to 'Go Get PhotoTaken data' that would then do the extraction and update the media item...
or if you want to do a full sweep of the existing Media in one go...
... you could use the MediaService, GetRootMedia() method to get the top level media items, and then use the .Children property of each media item to iteratively loop through the Media section, check for the phototaken date, and if it's not filled in, try and get the Media Item and extract it... depending on how much media you have... could take a while!
Extract Picture Date
I have a web site that primarily show pictures. I'd like to use the actual date the picture was taken, not the create date in Umbraco. This is especially true when I go on a trip and don't load the pictures into Umbraco until I return.
This question has two parts, hopefully the same answer.
I would prefer to do this as a field within Umbraco, not at render time.
The first case is to go through all of the existing pictures and extract the date the picture was taken and upload the item in Umbraco.
The second case is to extract the date the picture was taken when new pictures are uploaded.
I don't believe there is such a plugin available yet (I looked). Would someone be able to point me in the right direction?
Thanks!
Hi Gary
There was I believe this package in V8 to add a content app to show exif data
https://our.umbraco.com/packages/backoffice-extensions/media-info/
source here: https://github.com/prjseal/MediaInfo
It uses this tool: https://github.com/drewnoakes/metadata-extractor-dotnet
to do the extracting.
So I think from what you are describing you want to add a DateTaken property to the MediaType for Images...
Then you need a way to populate it.
When Media is uploaded to backoffice - the MediaService will fire the MediaSaved Notification
https://docs.umbraco.com/umbraco-cms/reference/notifications/mediaservice-notifications
within this you could get access to the uploaded image, read it's meta data and then update the Media Item in Umbraco with the DateTaken details...
Then for existing Media - you could either add a custom 'Menu Item' to the MediaTree using the MenuRenderingNotification
https://docs.umbraco.com/umbraco-cms/extending/section-trees/trees#menurenderingnotification
to give editors ability to choose to 'Go Get PhotoTaken data' that would then do the extraction and update the media item...
or if you want to do a full sweep of the existing Media in one go...
... you could use the MediaService, GetRootMedia() method to get the top level media items, and then use the .Children property of each media item to iteratively loop through the Media section, check for the phototaken date, and if it's not filled in, try and get the Media Item and extract it... depending on how much media you have... could take a while!
https://apidocs.umbraco.com/v9/csharp/api/Umbraco.Cms.Core.Services.IMediaService.html
regards
Marc
Hi Gary,
This is the code I use, it uses the metadata extractor mentioned by Marc
My code also uses the exif location which you may want to ignore :)
Wow! Thank you so much Marc and Huw! I guess my Sunday won't be entirely relaxing after all!
is working on a reply...