Text attachments should display in the browser, not forced downloaded

I like your MacGyver-style ingenuity. :D

But i think it's better to just make a add-on, just like the inline PDF add-on. Or something like option 2 in this post:
yes, how stupid of me. I didn't think about the forum add-ons. Most forums support plug-ins. I didn't research the subject with XenForo, then i moved on once you mentioned encrypted code. I will look at the official add-on documentation.

The link that you have provided contains the code that i mentioned in my earlier post:
Code:
$container['inlineImageTypes'] = function (Container $c) {
  return [
       'gif' => 'image/gif',
       'jpg' => 'image/jpeg',
       'txt' => 'text/plain'
  ];

extending c will do the trick (option 2). I have some things to do but i will read the official addon docs later and conjur up a viable solution. I have been studying C99 the past two weeks (which you already know), so i have to switch back into PHP mode...

Thanks for the link Mr. e :)

ps: atleast we could intercept when it is the only option. i considered that encrypted code may make it more difficult to add code without XenForo approval, so keeping it clean was the best route for me until now. Addon support is perfect! Thanks.
 
eternal_noob well, that was easy enough. I have my test forum setup based upon knowledge gathered about XenForo and i added the inline image extension to the src/config.php file. Voila! the text file opens in my browser.

config.php
Code:
$config['db']['host'] = 'localhost';
//more db config info probably encrypted

//add the following extension using an anonymous function and save the file.
$c -> extend('inlineImageTypes', function(array $imageTypes) {
    $imageTypes['txt'] = 'text/plain';
    return $imageTypes;
});

I named my forum folder xen and the path to config.php is: xen/src/config.php

problem solved! just have an Admin make the change on the server and text files will carry the Content-Disposition: inline header.
 
Back
Top