Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Foobar Studio

    (@foobarstudio)

    Hi,

    You can customize all the plugin HTML by using our template system. We have a full documentation of it there:

    https://wp-customerarea.com/documentation/developer-guides/the-template-system/

    Regards,

    Thread Starter adrianomicci

    (@adrianomicci)

    Hi, thank for your reply.
    I found customer-private-files-single-post-footer.template.php and cuar_the_attached_file_link($post->ID, $file).

    However in this way file will be downloaded also if I put its link in src of an iframe.
    Is there a method to get only the link without download it?

    Plugin Contributor Foobar Studio

    (@foobarstudio)

    You may try to add that:

    
    add_filter('cuar/private-content/files/default-action', 'wpca_change_default_file_actions', 10, 2);
    
            function wpca_change_default_file_actions($action, $attachment)
            {
                $ext = pathinfo($attachment['file'], PATHINFO_EXTENSION);
                $ext = strtolower($ext);
    
                if (strcmp($ext, 'pdf') === 0) return 'view';
    
                return $action;
            }
    
    Thread Starter adrianomicci

    (@adrianomicci)

    Thanks, it works perfectly!

    Plugin Contributor Foobar Studio

    (@foobarstudio)

    Glad to know that.

    Do not hesitate to post the iframe code here, as it may help others who would like to do the same thing.

    Regards,

    Thread Starter adrianomicci

    (@adrianomicci)

    Sure!

    Here the link

    <a href="javascript:void(0);" onclick="apriCatalogo('<?php cuar_the_attached_file_link($post->ID, $file); ?>')" class="btn btn-default btn-sm">
                                    <span class="fa fa-file-pdf-o"></span>
                                    <span class="hidden-xs"> Apri</span> </a>

    Here the div that will contain iframe
    <div id="cataloghi_iframe"></div>

    Here the javascript

    <script>
        function apriCatalogo( link ) {
            const iframe = '<iframe src="' + link + '" style="width: 100%;height: 100vh;"></iframe>';
            jQuery('#cataloghi_iframe').html( iframe );
        }
    </script>

    Very easy with your filter ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘View private file instead of download’ is closed to new replies.