Closed mowglisjungle closed 5 years ago
Hello - Do you mean you'd like to display the images directly inline, and that other content (video, etc) would somehow be embedded?
Hello, thank you for the reply. The users of the website I build prefer that their uploaded attachments rather just open then they have to download it first. Is something like this is possible?
Ah, I see what you're asking. ccb3421 adds a new filter that will allow you to set the Content-Disposition
header, like this:
add_filter(
'bp_docs_attachments_http_headers',
function( $headers, $filename ) {
$filename_parts = pathinfo( $filename );
$headers['Content-Disposition'] = 'download; filename="' . $filename_parts['basename'] . '"';
return $headers;
},
10,
2
);
The filter will be available in the next release of Docs, or you can patch your installation. The add_filter()
code can go in your theme's functions.php or some other file.
Hey! What he was asking for and what i also want is that if attached files could open in for example Google docs viewer instead of downloading it to your device. Would it be possible ?
Hello - Something like what's described above should change the way that the browser handles the file (forcing download rather than browser view, etc). I don't know how to open a document in Google Docs, but you may be able to use a similar header for this.
hey again! first of all, love your work! secondly, ive added the code but it still downloads all attached files to my pc when i click them.
would it be possible for you to add google viewer as a option when uploading the attatchment? all you gotta do is have a option to edit the URL for the document attached to docs with this: https://docs.google.com/viewer?url= www.yourdocumentsurlfile.com
I'm afraid I can't add an option for this, but you can probably do it yourself with a simple filter. This is untested, but the idea is that it should replace the download URL with the Google-embedded one:
add_filter(
'bp_docs_attachment_url_base'
function( $url, $attachment ) {
return 'https://docs.google.com/viewer?url=' . urlencode( wp_get_attachment_url( $attachment->ID ) );
},
10,
2
);
It's possible that this will not work with non-public attachments.
Hey man! works like a charm, thank you so much for your time
Hey again! As you Said only public documents can be used with the code you gave me, do you have any other way to open non-public files in website instead of downloading it to your device ?
Best I can offer is that you play with Content-Disposition
. https://github.com/boonebgorges/buddypress-docs/issues/659#issuecomment-521731262 https://coderanch.com/t/561315/java/display-pdf-file-broswer and other Google hits.
Hey again! As you Said only public documents can be used with the code you gave me, do you have any other way to open non-public files in website instead of downloading it to your device ?
hello, this is a good request, i'm need it too :( very nice work with this plugin so far
Hi,
my clients would preferably have the option to view the attachments in stead of a download link for the buddypress docs attachments. Any suggestions to solve this? Kind regards, Dirk