BuddyDev

Search

[Resolved] How to Add Meta Data (Upload Time) to Lightbox using PHP

  • Keymaster
    (BuddyDev Team)
    Posts: 24636
    Brajesh Singh on #5037

    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.

  • Participant
    Level: Enlightened
    Posts: 29
    Simon on #5052

    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!

  • Keymaster
    (BuddyDev Team)
    Posts: 24636
    Brajesh Singh on #5053

    Hi Simon,
    I am looking at it, will check and update the code Most probably some issue with format there.

  • Participant
    Level: Enlightened
    Posts: 29
    Simon on #5058

    Hi Brajesh,

    OK, thank you. I have been through a lot of the code myself in the BuddyPress files but I am struggling to work it all out, so your help is much appreciated.

    Thanks again,

    Simon

  • Keymaster
    (BuddyDev Team)
    Posts: 24636
    Brajesh Singh on #5078

    Hi Simon,
    There is an issue with my implementation. For now, Please use this instead

    
    
    echo mysql2date( get_option( 'date_format' ), $media->date_created , true );
    
    

    That will do it.

    Hope that helps.

  • Keymaster
    (BuddyDev Team)
    Posts: 24636
    Brajesh Singh on #5079

    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.

  • Participant
    Level: Enlightened
    Posts: 29
    Simon on #5080

    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!

  • Keymaster
    (BuddyDev Team)
    Posts: 24636
    Brajesh Singh on #5082

    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
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 29
    Simon on #5083

    Hi 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.

This topic is: resolved