Home › Forums › Front End PM PRO › Viewing Attachment rather than downloading attachment
Tagged: Attachment download view
- This topic has 4 replies, 2 voices, and was last updated 7 years, 1 month ago by Rob Storms.
- AuthorPosts
- November 2, 2018 at 11:11 pm #18741Rob StormsParticipant
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
November 3, 2018 at 11:15 pm #18763Shamim HasanKeymasterDo you know how to use wordpress hook? You can use
fep_filter_attachment_download_linkfilter hook so that you can update this plugin without losing changes.November 7, 2018 at 3:44 am #18840Rob StormsParticipantI’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?
November 7, 2018 at 7:40 pm #18877Shamim HasanKeymasterAdd 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);November 7, 2018 at 8:15 pm #18884Rob StormsParticipantWith a few tweaks, this worked perfect!
Thanks.
- AuthorPosts
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.