[Resolved] External File Link has extension removed

Home Forums Support External File Link has extension removed

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1230605
    Tim

    Hello

    When using a “URL” type ACF field to point to an external .pdf file “Publication Link”, when clicking on the link the file extension is removed, landing on a parent page.

    <figure class="publication-header-media">
     <?php
      $cover = get_field('cover');
      $size = 'full'; // (thumbnail, medium, large, full or custom size)
      $book_link = ( get_field('link') );
      if( $cover ) {
       echo '<a href="' . $book_link .'">' . wp_get_attachment_image( $cover, $size ) . '</a>';
      }
     ?>
    </figure> 

    I suppose this is a server redirect.

    If I enter the URL directly into the browser address bar, the pdf loads in the pdf viewer.

    Is there a way I can force the file to download / load in the pdf viewer ?

    #1231013
    David
    Staff
    Customer Support

    Hi there,

    include target="_blank" attribute in your <a> – this will open a new tab which should open the PDF.

    #1232021
    Tim

    Hmm

    target="_blank" is now in there, but no joy.

    #1232277
    David
    Staff
    Customer Support

    I think its a CORs issue:
    https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

    The browser is protecting the User by not allowing links from a different resource to be opened directly.

    #1233437
    Tim

    I thought CORS was for inline/on_page content, not for opening an outbound address.

    As a test I uploaded one of the pdfs to a different domain I manage. The link to that file opened as expected. So I don’t think the browser is protecting the visitor for this scenario.

    I suppose the target problem server is employing a redirect against “link leaches” or something.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.