[wp-trac] [WordPress Trac] #58082: Import metadata description from darktable into media caption in wordpress
WordPress Trac
noreply at wordpress.org
Tue Apr 4 15:12:04 UTC 2023
#58082: Import metadata description from darktable into media caption in wordpress
----------------------------+-----------------------------
Reporter: fotodrachen | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version: 6.2
Severity: normal | Keywords:
Focuses: |
----------------------------+-----------------------------
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,
descripton, 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 "descrition" can be used für 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 "ACSII 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
<?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'] );
}
}
}}}
Dokumentation in German: https://fotodrachen.de/wp/wordpress-
bildunterschrift-aus-darktable-metadaten-auslesen/
On long term it could be usefull also to import metadata from the Xmp-
group, for example to get different description and title.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58082>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list