• Resolved zkar

    (@zkar)


    Hello,
    I have a question regarding the “link” shortcode.

    I want to use the link=download shortcode. My problem is that I want the caption/title to be the downlaod link. But the default seems to be that the thumbnail becomes the download link.

    Is there a way to change this? Or do I have to manually create a download link around the caption shortcode?

    Thanks in advance!

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

    (@dglingren)

    Thanks for your question. If I understand you correctly, you are using [mla_gallery link=file] and you want to make the caption a link to the file in addition to the link provided behind the thumbnail image; is that right? If so, this earlier topic outlines a solution you can use:

    Attachment title as link

    For your application I suggest something like this:

    
    [mla_gallery]
    post_parent=all link=file size=thumbnail
    mla_caption='<a href="{+file_url+}" target="_blank">{+caption+}</a>'
    [/mla_gallery]
    

    The “enclosing shortcode” notation is now preferred to the old trick of using code tags around the shortcode. You can also try {+post_excerpt+} in place of {+caption+} and see which works better for your application.

    I am marking this topic resolved, but please update it if you have any problems or further questions regarding the above suggestions. Thanks for your interest in the plugin.

    • This reply was modified 9 years, 5 months ago by David Lingren.
    Thread Starter zkar

    (@zkar)

    Thank you for your fast answer!

    Yes I try to make an additional link. The thing is I want the link “Download” under my thumbnails not to be a normal link to the file url, but to force the link to open the download window/save file window directly. (like it does with the thumbnail when I click on it).

    My code looks like this now: [mla_gallery attachment_category='vorstand' link=download size='thumbnail' mla_caption='{+description+}<a href="{+file_url+}"><span class="load">{+post_excerpt+}</span></a>']

    As you can see I tried to built a gallery with thumbnails + a description and a download link with the {+post_excerpt+} (the input of my post excerpts are “Download” in the Media Gallery).

    The look is how I wanted it: See Screenshot but the link opens the file url and not the save file window.

    Is there a way to change this or am I trying the impossible?

    I hope this time I could describe my problem better… Again thanks for your help and time!

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your response and the clarification of your goal. I regret the haste of my first reply. To be honest, I had forgotten about the link=download option.

    The solution is similar but the details are different. You must change the {+file_url+} portion of your mla_caption parameter to something like:

    
    mla_caption='<a href="{+site_url+}/wp-content/plugins/media-library-assistant/includes/mla-file-downloader.php?mla_download_file=C:/Users/dlingren/Documents/My Data/Data Files/Web Design/VirtualHosts/mladev/wp-content/uploads/{+base_file+}" target="_blank">{+post_excerpt+}</a>'
    

    This is the link that works on my test system; you must change the upload directory path to conform to your own system, i.e., replace this portion:

    
    C:/Users/dlingren/Documents/My Data/Data Files/Web Design/VirtualHosts/mladev/wp-content/uploads/
    

    You can find the right value for your system by copying the link from one of your thumbnail images and finding the part that follows the mla_download_file= query argument name. If you have trouble with that post a link to the page on your site or one of the links behind a thumbnail image in your gallery.

    The above solution will work but I think it is inconvenient and painful. I plan to add two new substitution parameter values in my next version to make things easier:

    1. download_url – the complete href= value you need to create a download link for an item.
    2. upload_dir – the complete path to the uploads directory, as returned by the wp_upload_dir() function.

    Thanks for your patience and for inspiring an improvement in the plugin. Let me know if you have any problems or further questions regarding the above suggestions.

    Plugin Author David Lingren

    (@dglingren)

    I have done some further testing and have an improved solution:

    
    [mla_gallery]
    post_parent=all link=download size=thumbnail posts_per_page=6
    mla_caption='<a href="{+site_url+}/wp-content/plugins/media-library-assistant/includes/mla-file-downloader.php?mla_download_file={+base_dir,url+}/{+base_file,url+}&mla_download_type={+post_mime_type+}">{+post_title+}</a>'
    [/mla_gallery]
    

    It turns out I already have {+base_dir+} which eliminates the worst part of my first solution. I also discovered that you need to specify the ,url option so special characters and spaces in the value are encoded properly. Finally, you need to specify the MIME type of the image for the download to be processed.

    I regret any inconvenience caused by my first solution. Thanks for your understanding and your patience.

    Thread Starter zkar

    (@zkar)

    Your last solution worked perfect for what I was looking for.

    And again thank you really much for your help and time! 😀

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update with the good news. I am humbled once again to discover that the current MLA version already contains an even better solution for your application, the {+downloadlink_url+} substitution parameter. You can write the shortcode this way:

    
    
    [mla_gallery]
    post_parent=all link=download size=thumbnail posts_per_page=6
    mla_caption='<a href="{+downloadlink_url+}">{+post_title+}</a>'/mla_gallery]
    [/mla_gallery]
    

    I regret any inconvenience caused by my confusion. I really should spend more time reading the Settings/Media Library Assistant Documentation tab, which contains a description of the downloadlink and downloadlink_url substitution parameters.

    Thread Starter zkar

    (@zkar)

    This is a really nice solution! I also was a bit overwhelmed by the Documentation since I am using your Plugin the first time. I didn’t see the documantion section for the substitution parameters. Thank you very much for all your help!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘link download shortcode’ is closed to new replies.