#58082 closed defect (bug) (fixed)
Import metadata description from Darktable into media caption in WordPress
Reported by: | fotodrachen | Owned by: | joedolson |
---|---|---|---|
Milestone: | 6.5 | Priority: | normal |
Severity: | normal | Version: | 6.2 |
Component: | Media | Keywords: | has-patch commit |
Focuses: | Cc: |
Description (last modified by )
WordPress 6.2 in interaction with Darktable 4.2.1
It should be possible to set Metadata in the Photo-Editor "Darktable" that can be used as "caption" (and "title") in WordPress without typing it once again.
In Darktable there are 3 metadata-fields in the internal database: title, description, notices.
While exporting from Darktable to JPEG the metadata can be written into the JPG-file. There are 3 groups of metadata: EXIF, IPTC and Xmp.
Darktable writes EXIF and Xmp.
WordPress reads EXIF and IPTC.
So only EXIF can be used.
Darktable writes only the "description" into the EXIF-group, the fields "title" and "notices" only in Xmp.
So only the Darktable-field "description" can be used for WordPress-caption and title.
If the description has "ASCII only" characters, Darktable exports the description to "EXIF ImageDescription field".
If the description contains some special characters (like in german ä ö ü), then Darktable writes the Description to "EXIF UserComment field".
So "EXIF ImageDescription field" OR "EXIF UserComment field" is filled, but never both.
The "EXIF UserComment field" is not imported to the WordPress-caption when "EXIF ImageDescription field" is empty (wrong if-structure?).
So at least only descriptions with "ASCII only"-characters are imported from darktable, texts with special national characters are lost.
Please enable the import of the "EXIF UserComment field".
Source-code is: function wp_read_image_metadata()
in /wp-admin/includes/image.php
.
Inserting this 7 lines of code at line 877 solved the problem for me:
<?php // } } elseif ( empty( $meta['caption'] ) && ! empty( $exif['COMPUTED']['UserComment'] ) ) { $meta['caption'] = trim( $exif['COMPUTED']['UserComment'] ); $description_length = strlen( $exif['COMPUTED']['UserComment'] ); if ( empty( $meta['title'] ) && $description_length < 80 ) { $meta['title'] = trim( $exif['COMPUTED']['UserComment'] ); } }
Documentation in German: https://fotodrachen.de/wp/wordpress-bildunterschrift-aus-darktable-metadaten-auslesen/
On long term it could be useful also to import metadata from the Xmp-group, for example to get different description and title.
Attachments (9)
Change History (41)
#1
@
21 months ago
- Component changed from Administration to Media
- Description modified (diff)
- Summary changed from Import metadata description from darktable into media caption in wordpress to Import metadata description from Darktable into media caption in WordPress
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
21 months ago
This ticket was mentioned in Slack in #core-media by joedolson. View the logs.
19 months ago
#6
@
19 months ago
Our proposal is:
If identical, use ImageDescription; if one field is empty, use the one that's populated, if both populated, append in order ImageDescription + UserComment; add filter so plugins can adjust this behavior.
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
18 months ago
#10
@
17 months ago
- Milestone changed from 6.3 to 6.4
- Type changed from defect (bug) to enhancement
This ticket type is set as "bug" but it sounds more like an enhancement? Also seems it may be too late to add it to 6.3, RC is in few days.
Setting as enhancement and to the 6.4 milestone. Feel free to move it back to 6.3 if somebody is ready to test and fix this now.
#11
follow-up:
↓ 12
@
17 months ago
- Type changed from enhancement to defect (bug)
I think this should remain a bug; WordPress fails to read the appropriate description data out of the image meta in some circumstances, failing to follow the EXIF spec regarding multibyte characters when reading this data.
#12
in reply to:
↑ 11
@
17 months ago
Replying to joedolson:
Sure. In this case it seems that the EXIF "UserComment" should have a higher priority than the old, non-standard "Comment". I.e. the patch needs a small update.
#13
@
17 months ago
It's a bug and it's a small update.
The code for import the EXIF "UserComment" is already there. But it is wrapped in a wrong IF-structure (bug!).
A filled "UserComment" is only imported, when "ImageDescription" is also non-empty. This never happens for pics from DarkTable.
"ImageDescription" is filled for only-ascii text from the description-metadata in DarkTable, "UserComment" is filled for NOT-only-ascii text.
So "ImageDescription" OR "UserComment" is filled in the EXIF-data in a picture, but never both.
"UserComment" should be imported even if "ImageDescription" is empty, it's the alternative.
I added this case at the end of the if-else-structure. May be there is a smarter solution modifying a if-condition.
This ticket was mentioned in Slack in #core-media by joedolson. View the logs.
17 months ago
This ticket was mentioned in Slack in #core-media by joedolson. View the logs.
17 months ago
#17
@
16 months ago
- Keywords early removed
I've removed the early
keyword. Why?
The handbook explains the keyword as:
This keyword should only be applied by committers. The keyword signals that the ticket is a priority, and should be handled early in the next release cycle.
early
means the commits need to happen during the early part of the Alpha cycle; else, the ticket gets bumped.
Though it would be great to prepare the work for commit as early as possible, commits for this ticket should not be constrained to only happen during the early Alpha phase. Rather, defect commits can happen up to 6.4 RC 1.
To aid in 6.4 tracking and scrubs, I've removed the early
keyword.
#18
@
15 months ago
It seems that the description for this ticket is sufficient for testing info – although I'm sure some clear, concise testing steps would be appreciated by testing folks if anyone would be willing to add that to the ticket.
Could someone provide example images with metadata to cover all test cases? It seems like that would be needed for testing.
RC1 for 6.4 is ~2 weeks away so it would be great to get this tested ASAP so that it can be included. (cc @fotodrachen)
Thanks :)
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
15 months ago
#20
@
14 months ago
I added two example-pictures:
$ exiv2 -pa example_*.jpg | grep WP-Test example_without_umlaut.jpg Exif.Image.ImageDescription Ascii 32 WP-Test Description ohne Umlaut example_without_umlaut.jpg Xmp.acdsee.notes XmpText 27 WP-Test Comment ohne Umlaut example_without_umlaut.jpg Xmp.dc.title LangAlt 1 lang="x-default" WP-Test Title ohne Umlaut example_without_umlaut.jpg Xmp.dc.description LangAlt 1 lang="x-default" WP-Test Description ohne Umlaut example_with_umlaut.jpg Exif.Photo.UserComment Undefined 53 WP-Test Description mit Umlaut ÄÖÜäöüß example_with_umlaut.jpg Xmp.acdsee.notes XmpText 41 WP-Test Comment mit Umlaut ÄÖÜäöüß example_with_umlaut.jpg Xmp.dc.title LangAlt 1 lang="x-default" WP-Test Title mit Umlaut ÄÖÜäöüß example_with_umlaut.jpg Xmp.dc.description LangAlt 1 lang="x-default" WP-Test Description mit Umlaut ÄÖÜäöüß
This ticket was mentioned in PR #5430 on WordPress/wordpress-develop by @joedolson.
14 months ago
#21
Updates patch 58082.diff & handles case where both ImageDescription and UserComments are added.
Trac ticket: https://core.trac.wordpress.org/ticket/58082
This ticket was mentioned in Slack in #core-test by oglekler. View the logs.
14 months ago
#23
@
14 months ago
PR adds cases and updates tests. Test test_exif_d70_mf()
failed because this change causes the 'caption' value to be replaced by user comments when it is available; previously that image would have had an empty caption. It also results in the previously empty 'title' field being filled by the user comments field.
#24
@
14 months ago
Wonderful! @fotodrachen would you be willing to test PR 5430 5430.diff to see if the issue you reported here is resolved and submit a test report?
#25
@
14 months ago
Sorry, I can't do that. Actually I have no time, generally I did not have the skills.
But #comment:22 looks successfull for me.
#26
@
14 months ago
- Milestone changed from 6.4 to 6.5
We still need more test reports and have only a day before RC1, so, even if the patch looks fine, I am moving this to the next milestone for proper testing.
This ticket was mentioned in Slack in #core-media by joedolson. View the logs.
14 months ago
This ticket was mentioned in Slack in #core-media by joedolson. View the logs.
11 months ago
#29
@
11 months ago
- Keywords needs-testing removed
Test Report
This report validates that the indicated patch addresses the issue.
Patch tested: https://github.com/WordPress/wordpress-develop/pull/5430
Environment
- OS: macOS 14.2.1
- Web Server: Nginx
- PHP: 8.2
- WordPress: 6.5-alpha-56966-src
- Browser: Chrome 120.0.6099.199
- Theme: Twenty Twenty-Four
- Active Plugins:
- None
Actual Results
- ✅ Issue resolved with patch. Confirmed both with and without umlaut is working as intended.
Additional Notes
- Confirmed new test changes were passing
Screenshots to follow
@joedolson commented on PR #5430:
11 months ago
#32
Fixed in r57267
Hello @fotodrachen ! We reviewed this ticket in the recent Core Media meeting and think there is some improvement that could be made Core side to make this a better experience. Standards suggest UserComment as the intended substitute for ImageDescription when multibyte characters are needed. One way forward might be to append the UserComment if defined to ImageDescription.
And for future reference, here's the exif standard: https://www.kodak.com/global/plugins/acrobat/en/service/digCam/exifStandard2.pdf