Viewing Attachment rather than downloading attachment


Home Forums Front End PM PRO Viewing Attachment rather than downloading attachment

This topic is: Resolved
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #18741
    Rob Storms
    Participant

    I would like my users to be able to view attachments, rather than download them.

    I’ve made a change to the codebase (class-fep-attachment.php):

    
    //                              echo apply_filters( 'fep_filter_attachment_download_link', '<a> $attachment->att_id, 'fep_parent_id' => $attachment->mgs_id ) ) . '" title="' . sprintf( __( 'Download %s', 'front-end-pm' ), esc_attr( $name ) ) . '">' . esc_html( $name ) . '</a>', $attachment->att_id );
    
                                    echo apply_filters( 'fep_filter_attachment_download_link', '<a target="_" rel="noopener">att_file . '" title="' . sprintf( __( 'View %s', 'front-end-pm' ), esc_attr( $name ) ) . '">' . esc_html( $name ) . '</a>', $attachment->att_id );
    

    However with this change to the codebase, I won’t be able to upgrade.

    Let me know how you recommend handling this.

    Thanks

    #18763
    shamim
    Keymaster

    Do you know how to use wordpress hook? You can use fep_filter_attachment_download_link filter hook so that you can update this plugin without losing changes.

    #18840
    Rob Storms
    Participant

    I’m a pretty sharp guy, but I’ll need a little more to go on here.

    Specifically how do I get my attachment’s filename from within my newly created filter hook’s function?

    #18877
    shamim
    Keymaster

    Add following code in your theme’s (child theme’s if you are using) functions.php

    add_filter( 'fep_filter_attachment_download_link', function( $link, $att_id ){
        $attachment = FEP_Attachments::init()->get( fep_get_the_id(), $att_id );
        $name = basename( $attachment->att_file );
        $link = '<a href="' . fep_query_url( 'view-download', array( 'fep_id' => $attachment->att_id, 'fep_parent_id' => $attachment->mgs_id ) ) . '" title="' . sprintf( __( 'View %s', 'front-end-pm' ), esc_attr( $name ) ) . '">' . esc_html( $name ) . '</a>';
    
        return $link;
    }, 10, 2);
    
    #18884
    Rob Storms
    Participant

    With a few tweaks, this worked perfect!

    Thanks.

Viewing 5 posts - 1 through 5 (of 5 total)

You need to purchase ‘Front End PM PRO’ to create topic in this support forum.

If you already purchased ‘Front End PM PRO’ please LOGIN.