Hi,
I was wondering whether it would be possible to display "original date taken" under the thumbnail on an album. Looking at the source of image.php, I see that image metadata is retrieved by a single function call:
`printImageMetadata_zb()`
and in the browser I see that this is rendered in a table, leading me to think it may not be possible to retrieve and display solely the date taken.
Along similar lines, it would be nice display the date an image was added on the home page configured to display Latest pictures (I'm adapting the Paradigm theme). Any ideas how I might go about doing this?
Disclaimer: I'm not a PHP programmer, just a tweaker
Comments
But you can get respectively print any field using these:
http://www.zenphoto.org/documentation/functions/_template-functions.php.html#functiongetImageData
http://www.zenphoto.org/documentation/functions/_template-functions.php.html#functionprintImageData
I thought it would be helpful to see those two functions in action, so I switched to the default Basic theme. On the image page, "Original Time Taken" which is what I am after.
I open image.php in an editor and these seem to be the lines:
`
if (getImageMetaData()) {
printImageMetadata(NULL, 'colorbox_meta');
?>
`
But that doesn't tell me much about how those two functions are showing the specific fields.
What is "colorbox_meta"?
'colorbox_meta" triggers the lightbox display of the meta data table output some official themes use.
If you want a specific field you need to use the functions I linked above.
`
<?php
if(getImageMetaData()){
printImageData('EXIFDateTimeOriginal', 'Original Time Taken: ');
}
?>
`
`EXIFDateTimeOriginal` is the metadata (database) field you want and
`Original Time Taken:` is an arbitrary text to prepend the output with.
If you select a home page displaying the latest images, this is generated by this call:
`printLatestImages_zb(12, "", true, true, false, "", false,NULL,NULL,NULL, "", true); }`
I looked in the functions.php file and found this:
`
if ($showdate) {
echo "
" . zpFormattedDate(DATE_FORMAT, strtotime($image->getDateTime())) . "
";}
`
So, changing the fourth parameter to "true" is all that is needed. No programming required
The only slightly disconcerting thing is that the Latest here is latest added, but the the *creation date* is displayed, so if you add a picture you took a few years ago, it nonetheless appears on the home page under Latest. Seems to me the date displayed under Latest should be the date added to the site <shrug>
If anyone wants to see what it looks like in action, here is the site I am building (work very much in progress):
https://thelowcountry.nl/
I'm going to work now on formatting those dates, among other stuff.
Thanks for the helpful information. Although I have some basic programming experience and I am comfortable editing PHP files, it is difficult for me to learn the specific syntax simply from looking at the documentation.
This works fine here:
`
<? php
if(getImageMetaData()){
printImageData('EXIFDateTimeOriginal', 'Original Time Taken: ');
}
?>
`
Only the date format is not ideal. According to the documentation referred to above, there is also a format parameter.
Using this page as a reference: http://us2.php.net/manual/en/function.strftime.php
I thought that something like this would look nice: %d %B %Y
But adding this as a parameter has no effect:
`
<? php
if(getImageMetaData()){
printImageData('EXIFDateTimeOriginal', 'Original Time Taken: ','%d %B %Y');
}
?>
`
But this has no effect. Any ideas?
I am trying to add the DateTime to the template's _imagethumbnail.php page, which isn't possible using the option I mention above that is available for the latest image display.
Thanks for your patience
Of course `printImageData('EXIFDateTimeOriginal', 'Original Time Taken: ','%d %B %Y');`has no effect as the function has no parameter for that. You really should look at the functions documentation when using them:
http://www.zenphoto.org/documentation/functions/_template-functions.php.html#functionprintImageMetadata
How to read the documentation is explained here:
http://www.zenphoto.org/news/how-to-read-the-zenphoto-functions-guide
You have to put the value into a variable first using the `get` version and then and then use the above functions on it. Sorry this is rather PHP basics we really cannot cover here ;-)
`
<?php
if(getImageMetaData()){
$mydate = date_create_from_format('Y:m:d H:i:s', getImageData('EXIFDateTimeOriginal'));
echo 'Original Time Taken: ' . $mydate->format('d-m-Y');
}
?>
`
IF the EXIF date information is embedded in the image and IF Admin > Options > Image > Metadata > "Original Time Taken" is checked, the stored date will be read and it's format changed to the desired output format.
@fretzl: Very helpful, thanks; got it working. I see now that my scanned 35mm pics don't have that date field and I will be adding it with exiftool.