Support » Plugin: Media Library Assistant » Media upload date

  • Resolved Kompozitor

    (@kompoghp)


    Hi, I’m using your plugin which I love.

    I’m trying to do something quite specific on my site:
    I’m selling the pdf scores of the music I compose.

    Sometimes I update the pdf files when I had a to fix it (typos, new versions)
    I’d like to display on the frontend the upload date of the pdf file attached to the post to so that people know which version they download.

    I was wondering if there is any way to display this date with one of the shortcodes of your plugin.

    Thanks a lot in advance

    Greg

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thanks for your question, the positive feedback, and thanks for including a link to your beautiful site; very helpful.

    The most complete answer is to use MLA’s custom style and markup templates to get complete control over the content and appearance of your gallery. Here is one example of that approach in an earlier topic:

    Clever document insert with MLA

    As you can see, it’s powerful but requires some work on your part. You can also add parameters to your shortcode to get some simple results:

    [mla_gallery]
    post_mime_type="application/pdf" post_parent=all
    link=file mla_target="_blank"
    size=icon columns=1 orderby=title
    mla_caption='<a href="{+file_url+}" target="_blank">{+title+}, uploaded: {+date+}</a>'
    [ /mla_gallery]
    

    I have used the alternate “enclosing shortcode” syntax to break the parameters across several lines for readability.

    • The first line selects all PDFs in the Media Library.
    • The second line links each thumbnail directly to the PDF file and opens up the file in a new browser window.
    • The third line sets the size of the gallery thumbnails, the number of thumbnails in each gallery row and the sort order of the gallery.
    • The last line makes the caption below each item a clickable link to the PDF and displays the item Title and the upload date.

    You might also try using MLA to find the items matching the tag and use another plugin to generate the gallery display. Look in these sections of the Documentation tab for more information:

    • Support for Other Gallery-generating Shortcodes
    • Support for the “Photonic Gallery” Plugin

    That’s more than you asked for but I want to give you a sense of the range of options available with the [mla_gallery] shortcode. You can find more information about PDF galleries in this earlier topic and the topics it links to:

    Just start with it

    I hope that gets you started on a solution for your application. I am marking this topic resolved, but please update it if you have problems or further questions regarding the above suggestions. Thanks for your interest in the plugin.

    Hi,
    sorry for very very late answer I’ve been caught in other activities that lead me to put this topic aside for a while

    Actually I created this template
    <[+itemtag+] class=’tnb-lastupdate’>
    [+upload_date,date(‘d F Y’)+]
    </[+itemtag+]>

    as I just need the date, nothing more.

    But now I’m facing another problem
    This date has to be translated
    so I used the Markup in a php snippet
    as following

    $var= do_shortcode( ‘[mla_gallery post_parent=”current” post_mime_type=application/pdf mla_markup=tnb-lastupdate]’ );
    $timestamp= strtotime($var);
    echo date_i18n( ‘d F Y’,$timestampà);

    but the $timestamp variable always ends up empty as if the strtotime function does not recogize the content of the variable.

    would it be possible to retrieve the upload_date directly as a unix timestamp ?

    Thanks in advance

    Greg

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update with the details on your progress.

    I suspect the $timestamp variable is empty because the value returned from your do_shortcode includes some markup in addition to the upload_date value. You could retrieve the upload_date as a timestamp by coding [+upload_date,date(‘U’)+] but you would still have some markup around it.

    After some thought and investigation I decided to add a new feature to the date() option/format code that might give you what you need.

    I have uploaded a new MLA Development Version dated 20190302 that contains the new feature. You can find step-by-step instructions for using the Development Version in this earlier topic:

    PHP Warning on media upload with Polylang

    With the Development Version you can use the [mla_gallery] shortcode to display the localized date. For example, you can change your template to something like:

    
    <[+itemtag+] class=’tnb-lastupdate’>
    [+upload_date,date(‘d F Y’,i18n)+]
    </[+itemtag+]>
    

    The new i18n argument directs MLA to use the date_i18n function to produce a localized date.

    It would be great if you can install the Development Version and let me know if it works for you. I will set this topic to unresolved until I hear back from you. Thanks for inspiring this new MLA feature and for your interest in the plugin.

    Hi
    Thanks a lot, that’s great and it works perfectly

    there is only a tiny detail
    the date is displayed in between commas ’20 mars 2019′

    I didn’t find how to get rid of them

    Plugin Author David Lingren

    (@dglingren)

    Thanks for trying the Development Version and for the good news that it’s working for you.

    I copied your template to my test system and reproduced the “displayed in between commas” problem you are having. The “commas” are actually “smart quotes” generated when you posted your template above. I regret that I repeated the error when I posted my updated template in my last reply. Simply change the quotes back to simple UTF/ASCII quotes:

    <[+itemtag+] class='tnb-lastupdate'>
    [+upload_date,date('d F Y',i18n)+]
    </[+itemtag+]>
    

    Look carefully at the above code and you will see the difference. Again, I regret the confusion and I hope that will solve your problem.

    Works like a charm !

    Thanks a lot, this is very helpful and convenient

    Plugin Author David Lingren

    (@dglingren)

    I have released MLA version 2.79, which contains the new features for your application.

    I am marking this topic resolved, but please update it if you have any trouble with the new version. Thanks again for your help with this MLA improvement.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Media upload date’ is closed to new replies.