Cannot open PDFs
-
Hello,
this is a great plugin. Perhaps too great for me, because I cannot solve an error.
I am trying to display a number of PDFs with this Shortcode:
[mla_gallery link=file post_mime_type=application/pdf ids=”1,2,3″]
What I see in the FrontEnd are the correct thumbnails of the PDFs.
When I click on them I see my default lightbox viewer, as with [gallery].
But the PDFs won’t open and there’s no way to click on them, the spinner rotates on forever.When I try “…link=file mla_named_transfer=true…” I get a forced download of admin-ajax.pdf, but the PDF file is the right one.
What I’d like to achieve is to have clickable thumbnails, but instead of opening a lightbox viewer or forcing a download, I’d just like to open them in the browser. Preferrably with the nice mla_named_transfer=true option.
What did I do wrong?
Thanks ??
-
Thanks for your positive feedback and for the question. Thanks as well for the details and your shortcode text.
I believe you can get the results you seek by adding an
mla_target="_blank"
parameter to your shortcode. Both of these examples are working well on my system with the Microsoft Edge and Chrome browsers:[mla_gallery post_mime_type=application/pdf post_parent=all link=file mla_target="_blank"] [mla_gallery post_mime_type=application/pdf post_parent=all link=file mla_named_transfer=true mla_target="_blank"]
When I click on a thumbnail the PDF document opens in a new browser tab. You wrote “When I click on them I see my default lightbox viewer, as with [gallery].” It is possible that your theme is interfering with the document display.
I am marking this topic resolved, but please update it if you have problems or further questions regarding the above suggestions. If you still have a lightbox issue, post a link to the page you’re having trouble with and I will investigate further. Thanks for your interest in the plugin.
Hello,
sorry for the late reply, and thanks for your answer. With your code
[mla_gallery post_mime_type=application/pdf post_parent=all link=file mla_target="_blank" mla_named_transfer=true]
I get a list of thumbnails with this (obscured) link structure:
…/admin-ajax.php?action=mla_named_transfer&mla_item=mypdfname&mla_disposition=inline.
Clicking on them starts a download of admin-ajax.pdf, which ist the correct file, just with the wrong name.
This code
[mla_gallery post_mime_type=application/pdf post_parent=all link=file mla_target="_blank"]
gives me the same list of thumbnails with a different link structure:
/wp-content/uploads/2022/03/mypdfname.pdfand clicking on them downloads the right file with the right name.
Can I have “best of both worlds”? ?? The right filename AND the obscured link structure?
Thanks a lot!
-
This reply was modified 2 years, 10 months ago by
Gerdski.
Thanks for your update with the good news on your progress. The
admin-ajax.php
refers to the WordPress code that processes the download request; it cannot be changed directly.You might find a solution in the “MLA Item Transfer Pretty Links” example plugin, created for this earlier topic:
How about [mla_gallery list=mask]?
Have a look at that topic and the example plugin and let me know if it works for you.
Hello,
thanks for your reply.
I installed the other plugin, but [mla_gallery list=mask] shows nothing.
But maybe I haven’t understood the earlier topic you were linking to.I failed at “I created a “publication” for a PDF file and looked at the corresponding single publication page, which lists the document title, file name and links for “view” and “download”. Does this mean that I have to create a “publication” for every PDF file? This would make things hard for the customer, who is not a web developer ??
But it doesn’t matter too much, I just thought that te obfuscation of the download link would be a nice security feature. I can use maybe .htaccess to hide files to non-logged-in-users.
Thanks a lot!
Thanks for finding and installing the example plugin I suggested. I regret that the instructions for using it are not very clear; I will update the settings page to give more details along the lines of these remarks in the earlier topic:
The
mla_named_transfer=true
parameter implements the “simple” approach described in the Settings/Media Library Assistant Documentation tab. The example plugin adds the “more complex” alternative, transforming the links from theadmin-ajax.php
format to something like:https://www.mysite.com/mla-transfer/view/my-item-slug https://www.mysite.com/mla-transfer/download/my-item-slug
The example plugin adds a Settings/MLA Pretty Links page that allows you to change the “mla-transfer”, “download” and “view” portions of the pretty links. It will transform any [mla_gallery] shortcode containing a mla_named_transfer=true parameter.
The
list=mask
parameter was a suggestion from the person who started the earlier topic; I did not use it in the actual implementation. All you have to do is install and activate the example plugin and addmla_named_transfer=true
to your shortcode(s).Let me know if that works for you.
Hello,
thanks for your reply.
I have installed and activated WP Publication Archive Plugin (but have done nothing else with it).
With this shortcode:
[mla_gallery post_mime_type=application/pdf post_parent=all link=file mla_target="_blank" mla_named_transfer=true]
I am getting the same results, no matter if the plugin is active or not:
A download with the name of admin-ajax.pdfMaybe I must do something with the other Plugin, but I have no Idea how it works…
Thanks for your update. I am not sure what the “WP Publication Archive Plugin” is, but it is not the plugin I recommended for your application. From the earlier topic:
To install the example plugin, navigate to the Settings/Media library Assistant Documentation tab and click the “Example Plugins” button. You will see a table that lists all the example plugins and gives you a “one-click” action for installing them. Type “pretty” in the text box and click “Search Plugins” to filter the table. You are looking for the “MLA Item Transfer Pretty Links” example plugin. Find that plugin and hover over the title in the left-most column. Click the “Install” rollover action, then go to the WordPress Plugins/Installed Plugins submenu and activate it as you would any other plugin.
Please try the “MLA Item Transfer Pretty Links” example plugin and see if it helps. Thanks..
Hello,
I think I know why there was a misunderstanding about the right plugin:
In the link you gave me:
https://www.ads-software.com/support/topic/how-about-mla_gallery-listmask/#post-9679887
the user “lwcorp” speaks of this plugin:
https://www.ads-software.com/plugins/wp-publication-archive/
but you meant this one:
MLA Item Transfer Pretty Links.Will try that now…
Thanks for your great support! Sorry that my reply took so long…it is because the customer’s reply took so long :-/
OK, I have activated the MLA Item Transfer Pretty Links Plugin.(Wow…you wrote 75 Plugins for your main plugin!)
This Shortcode here gives me the link in a good format: /mla-transfer/view/mypdfname, but I get admin-ajax.pdf for download:
[mla_gallery post_mime_type=application/pdf post_parent=all link=file
mla_target=”_blank” mla_named_transfer=true include=”1,2,3″]While this one here gives me the full path to /wp-content/2022/06/mypdfname.pdf, and I get mypdfname.pdf for download:
[mla_gallery post_mime_type=application/pdf post_parent=all link=file mla_target=”_blank” include=”1,2,3″]So, sorry to say, but it does not work for me yet.
Is there something wrong with my shortcode?
Thanks!
Thanks for your updates and for reporting your results.
You wrote “ I get admin-ajax.pdf for download“. I copied your shortcode to my test system and ran a test. As you wrote, the link embedded in the gallery item has the
/mla-transfer/view/
form generated by the Pretty Links plugin. When I click on the item, the document is downloaded and opens in a new browser tab. The URL displayed in the browser navigation text box has the form:https://mysite.com/wp-admin/admin-ajax.php?action=mla_named_transfer&mla_item=myitemd&mla_disposition=inline
Is that what you mean when you write “I get admin-ajax.pdf for download“? If so, I regret to confirm that this is a function of the way the browser and server work and I do not know any way to change that at this time. If you want to see the “pretty” link in the browser navigation text box I can look for a solution but I cannot promise a good result. Let me know if I understand you correctly and thanks for your understanding of my response.
> Is that what you mean when you write “I get admin-ajax.pdf for download“?
Yes. The browser wants to download admin-ajax.pdf, and it has the contents of the desired PDF.
> If you want to see the “pretty” link in the browser navigation text box I can look for a solution
No, that’s not necessary.
I was looking for a way to change the name from admin-ajax.pdf to the original file name of the pdf. If that’s not possible: no problem…the customer has just decided to display the PDF file name instad of the PDF preview, so there is no immediate solution needed any more.
I’ll definitely use your plugin/s in future projects where pretty links don’t need to be obfuscated ??
Thanks a lot for your help!
Thanks for confirming my understanding of your issue.
For others reading this topic in the future, let me give a more complete description of what is happening. The browser does not “download admin-ajax.pdf”.
The URL invokes the PHP code in the file
admin-ajax.php
. That code intreprets theaction=mla_named_transfer
argument and runs some PHP code within MLA, passing themla_item=myitemd
andmla_disposition=inline
arguments to the MLA code. The MLA code
finds the item named bymla_item
and then downloads the file “attached” to that item.The “MLA Item Transfer Pretty Links” plugin translates the original URL, e.g.,
/mla-transfer/view/myitemd
to the format required to perform the transfer. As I wrote, it might be possible to restore this original URL in the response returned from the transfer, but I have not looked into whether that is possible.I hope that gives you and other MLA users a more detailed understanding of the process. I am marking this topic resolved, but please update it if you have problems or further questions about this MLA feature and example plugin. I hope you find MLA of use in future projects!
-
This reply was modified 2 years, 10 months ago by
- The topic ‘Cannot open PDFs’ is closed to new replies.