alright,
this post quite helped so far and seem to be doing what I want to achieve.
My newbie question would be that I don’t know where to use this plugin code?
<?php
// Get keywords from IPTC data
function iptc_keywords($image) {
$size = getimagesize($image->url(), $info);
if(isset($info['APP13'])){
$iptc = iptcparse($info['APP13']);
// Get keywords
$keywords = '';
$keywordcount = count($iptc["2#025"]);
for ($i=0; $i < $keywordcount; $i++) {
$keywords .= $iptc['2#025'][$i].', ';
}
$keywords = rtrim($keywords,', ');
return $keywords;
}
};
kirby()->hook(['panel.file.upload'], function($image) {
if ($image->type() == 'image') {
// Get date created from exif data
$datecreated = $image->exif()->timestamp();
// Get keywords via function
$keywords = iptc_keywords($image);
// Update image metadata
$image->update(array(
'date' => $datecreated,
'tags' => $keywords
));
}
});
Thanks