Page 1 of 1

opening attachments in a new window

Posted: May 09, 2018 6:51 am
by didds
mantisbt 2.5.0
Apache/2.4.6
CentOS Linux release 7.4.1708 (Core)

newly provisioned version of 2.5.0

Image and PDF attachments to a call are opened in the same window if subsequently clicked on, requiring a return to the original call if updates are needed.

is there a simple tweak that will permit opening in a separate window?

(I did search but the only hit I found was for a very old version of Mantis 1.2.3)

cheers

didds

Re: opening attachments in a new window

Posted: May 16, 2018 10:33 am
by didds
Having done some more tests...

* a text file gets the option to save or open it (separate dialogue box)
* a png file gets opened in the same window
* a pdf file gets opened in the same window

what is the config_inc.php variable that affects this? It wold make more sense to have all attachments provided with the option to "open or save" rather than just open in a browser window

cheers

didds

Re: opening attachments in a new window

Posted: May 16, 2018 10:43 am
by atrol
Copy the following piece of code (defaults from config_defaults_inc.php) to your config_inc.php and adjust to your needs

Code: Select all

/**
 * Specifies the maximum size (in bytes) below which an attachment is
 * previewed in the bug view pages.
 * To disable the previewing of attachments, set max size to 0.
 * @global integer $g_preview_attachments_inline_max_size
 */
$g_preview_attachments_inline_max_size = 256 * 1024;

/**
 * Extensions for text files that can be expanded inline.
 * @global array $g_preview_text_extensions
 */
$g_preview_text_extensions = array(
	'', 'txt', 'diff', 'patch'
);

/**
 * Extensions for images that can be expanded inline.
 * @global array $g_preview_image_extensions
 */
$g_preview_image_extensions = array(
	'bmp', 'png', 'gif', 'jpg', 'jpeg'
);

Re: opening attachments in a new window

Posted: Oct 09, 2018 7:04 pm
by zoziano
it dosent working for me

Re: opening attachments in a new window

Posted: Oct 10, 2018 4:34 am
by cas
so be more precise, what does not work and actually what happens ?

Re: opening attachments in a new window

Posted: Oct 11, 2018 3:58 am
by DanielLeeeee
have just the same issue

Re: opening attachments in a new window

Posted: Mar 05, 2020 4:31 am
by martin.fernau
cas wrote:
Oct 10, 2018 4:34 am
so be more precise, what does not work and actually what happens ?
What the OP means is that attachments like a PDF should be opened in a new Window/Tab instead of overriding the currently opened topic of mantis.
If I read a topic in mantis and see an attached pdf I'll click on it to read the content. Currently it openes in the same window/tab as the currently viewed mantis topic. My intuitive action is to close the window/tab after finally reading the pdf which leads to the problem that the mantis topic itself is closed which wan't my intention.
For me such files should be opened in new window/tab so that I can close the pdf like any other pages and returning to the mantis topic.

I think mantis should just add a target=”_blank” to the attachment links

Re: opening attachments in a new window

Posted: Mar 05, 2020 12:26 pm
by atrol
@martin.fernau not sure you are aware that
a) there is a standard functionality of most browsers, where you can hold Ctrl key while clicking a link to open n a new tab and Shift key to open in a new window
b) there is option $g_html_make_links https://mantisbt.org/docs/master/en-US/ ... onfig.html

Re: opening attachments in a new window

Posted: Mar 06, 2020 3:01 am
by martin.fernau
atrol wrote:
Mar 05, 2020 12:26 pm
@martin.fernau not sure you are aware that
a) there is a standard functionality of most browsers, where you can hold Ctrl key while clicking a link to open n a new tab and Shift key to open in a new window
b) there is option $g_html_make_links https://mantisbt.org/docs/master/en-US/ ... onfig.html
Sure, I'm aware of this functionality and I regularly use it on other websites if I want to open links to other sites into a new tab.
Please try to understand that we're not talking about "links to other sites". We're talking about attachments and thus the $g_html_make_links configuration does not work here (I even set it to $g_html_make_links = LINKS_NEW_WINDOW).
To be even more precise take a look at my screenshot.
If I click an attachment - for me it would be intuitive that this attachment is opened in a new tab and not "over" the currently viewed bug entry. I often get asked by my colleagues if we're able to change the current behavior to let the attachments open in a new tab. This is a confirmation for me that the current behavior "opening attachments in the active tab" isn't really intuitive.

Re: opening attachments in a new window

Posted: Mar 06, 2020 5:05 am
by atrol
I understand that this is a good solution for your users and your workflow.
I don't like it that much, as I have opened sometimes quite a lot of tabs, get distracted and later it's good to have a "Back" button.

There is some discussion around PDF display, e.g. search the web for something like "open pdf in new tab"
Using target=“_blank“ is at least questionable, check https://css-tricks.com/use-target_blank/ https://www.media-affin.de/blog/gruende ... rget-blank

As always, if there is not a single right way to do it, we would need a user specific configuration option in Mantis.
If I understand right, the option must also be file type specific, as you might want this behavior for PDF, but not JPG as inline preview of JPG is quite convenient.

Independant from that, there can't be an implementation that works for all.
There are browsers that are
- not able to display PDF themselves, but need an external viewer.
- able to display PDF, but there are configuration options to change it (e.g. display, download, open external viewer)
- able to display PDF, but they don't support your special PDF the right way

Introducing an option that covers all these aspects is something where "normal" users without technical background will struggle in configuring it.
Maybe you have an idea for a simpler approach?

You could
- open a feature request at www.mantisbt.org/bugs, maybe someone in the community (you?) is interested / able in implementing it
- change the original Mantis source the way you need it (if you are using Git, you could maintain your own branch, making it easy to change again when upgrading to a newer version)
- write a plugin that uses JavaScript to tweak the links the way you want it.
- as you seem to use Chrome, you could configure Chrome to open an external viewer
- ...

Re: opening attachments in a new window

Posted: Mar 06, 2020 5:31 am
by martin.fernau
Thanks for your detailed answer atrol. I understand your point of view in this manner and you're right that having an option of all and everything might be a bit of too much..

I'll see how I can solve this 'problem' for my purposes in a way that don't need a code change of mantis itself.

Re: opening attachments in a new window

Posted: Jul 16, 2020 12:30 am
by marthaneilson
On the off chance that I read a point in mantis and see a joined pdf I'll tap on it to peruse the substance. Right now it openes in a similar window/tab as the at present saw mantis point. My natural activity is to close the window/tab after at long last perusing the pdf which prompts the issue that the mantis point itself is shut which wan't my goal. For me such records ought to be opened in new window/tab with the goal that I can close the pdf like some other pages and coming back to the mantis subject