Hey I’m trying to make all .doc/docx .xls/xlsx files open in office online.
This would mean that every link to a .doc
http://mywebsite.com/wp-content/uploads.link.doc
would have to instead point to the office online preview link
https://view.officeapps.live.com/op/view.aspx?src=http://mywebsite.com/wp-content/uploads/link.doc
I’m not even sure how to go about doing this? Any help would be greatly appreciated!
Thanks!
I’m not sure this question is WordPress-related. It sounds like it might be handled via
.htaccess
redirect, or a browser extension.That said: you could try to use the
wp_get_attachment_url
filter, that is applied to the URL returned bywp_get_attachment_url()
.For example:
(This is completely untested, and presented as an example only.)
Edit
Just extend the conditional. Here’s an example, abstracted for clarity:
Just build your own link in your template, appending the attachment URL to your base URL, as done in the above filter.