Tagged: lightbox meta data
Hello,
I am slowly learning PHP and am currently customising the lightbox. By using PHP I was able to add the media title and description to the lightbox (lightbox-comment.php) but am struggling to work out how to add the meta data, such as the time when the media was uploaded.
How could I add the meta data to the lightbox?
Thanks!
Hi Simon,
The upload time is same as the attachment’s cration date. You can add the following code in the above php file. It will take the timefromat from your WordPresssettings and output the date/time.echo mpp_get_media_date_created( $media );
Here is what it does
return date_i18n( get_option( 'date_format' ), $media->date_created )
If you want to take care of the time format(independent of what you have in settings). You can work with
$media->date_created
Hope that helps.
Hi Brajesh,
Thanks for your help. I added your code [echo mpp_get_media_date_created( $media );] to lightbox-comment.php but it displays 01/01/1970 on all of the images in my gallery. What I need is the timestamp (I think this is what it is called) when the image was added (uploaded) to the gallery (and to activity), such as “Simon added a photo 4 days, 16 hours ago”.
Is this possible?
Thanks!
Hi Simon,
I am looking at it, will check and update the code Most probably some issue with format there.Hi Simon,
There is an issue with my implementation. For now, Please use this insteadecho mysql2date( get_option( 'date_format' ), $media->date_created , true );
That will do it.
Hope that helps.
Btw, I have updated the github repository with proper fix.
So,
echo mpp_get_media_date_created( $media );
Will work too if you are using the download from github.
Hi Brajesh,
Thanks! Your fix in #5078 works for me but for some reason the fix in #5079 still gives me 01/01/1970, even after I added the 3 new updates from GitHub. Have I done something wrong? I just copied and pasted the new code over the existing code for each of the 3 files. Is this correct?
Thanks!
Hi Simon,
I am sorry but I don’t know which changes you are mentioning.It will be better if you directly download the plugin as zip file and replace the current plugin with it.
That will make it work.
Thank you
BrajeshHi Brajesh,
Sorry I thought you meant the 3 new file updates you added to GitHub under the title “Update the docs a little bit”. Do you have a link for the correct download as I’m not sure how to find it, I can only find MediaPress 1.0.6, which I already have.
Thanks,
Simon
The topic ‘ [Resolved] How to Add Meta Data (Upload Time) to Lightbox using PHP’ is closed to new replies.