Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documents auto downloading instead of opening in current tab or new tab #752

Open
TAS1426 opened this issue May 13, 2024 · 4 comments
Open

Comments

@TAS1426
Copy link

TAS1426 commented May 13, 2024

We are having an issue where documents are automatically downloading when clicked on, instead of opening in the current tab, or a new tab. Also, the URL of the document trying to download has "?bp-attachment=", and is a different URL than what is in our Media section.

@boonebgorges
Copy link
Owner

buddypress-docs changes URLs to the format ?bp-attachment= when the plugin detects that your installation supports "protection" mode. This generally means you're running Apache, and buddypress-docs has managed to set up the necessary rewrite rules. This feature is intended to provide protection against non-authorized access to attachments.

As for the direct download, in general this is the intended behavior for Doc attachments. But there's a feature that allows you to filter the headers, allowing the browser to open the file where possible. See #659 (comment). See also #723.

@TAS1426
Copy link
Author

TAS1426 commented May 14, 2024

This is great. Thank you. It worked. One more question. Is there a way to have it open in a new tab that you're aware of?

@boonebgorges
Copy link
Owner

Something like this will probably work:

add_filter(
	'bp_docs_attachment_item_markup',
	function( $markup ) {
		$markup = str_replace( '<a ', '<a target="_blank" ', $markup );
		return $markup;
	}
);

@TAS1426
Copy link
Author

TAS1426 commented May 14, 2024

That worked. Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants