opening attachments in a new window

General discussion of Mantis.

Moderators: Developer, Contributor

Post Reply
didds
Posts: 22
Joined: Jan 18, 2017 11:24 am

opening attachments in a new window

Post 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

didds
Posts: 22
Joined: Jan 18, 2017 11:24 am

Re: opening attachments in a new window

Post 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

atrol
Site Admin
Posts: 7788
Joined: Mar 26, 2008 4:37 pm
Location: Germany

Re: opening attachments in a new window

Post 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'
);
Please use Search before posting and read the Manual

zoziano
Posts: 1
Joined: Oct 09, 2018 7:01 pm

Re: opening attachments in a new window

Post by zoziano »

it dosent working for me

cas
Posts: 805
Joined: Mar 11, 2006 11:08 am
Contact:

Re: opening attachments in a new window

Post by cas »

so be more precise, what does not work and actually what happens ?

DanielLeeeee
Posts: 1
Joined: Oct 11, 2018 3:53 am

Re: opening attachments in a new window

Post by DanielLeeeee »

have just the same issue

martin.fernau
Posts: 4
Joined: Nov 19, 2019 5:54 am

Re: opening attachments in a new window

Post 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

atrol
Site Admin
Posts: 7788
Joined: Mar 26, 2008 4:37 pm
Location: Germany

Re: opening attachments in a new window

Post 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
Please use Search before posting and read the Manual

martin.fernau
Posts: 4
Joined: Nov 19, 2019 5:54 am

Re: opening attachments in a new window

Post 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.
Attachments
Mantis_example.png
Mantis_example.png (310.39 KiB) Viewed 1896 times

atrol
Site Admin
Posts: 7788
Joined: Mar 26, 2008 4:37 pm
Location: Germany

Re: opening attachments in a new window

Post 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
- ...
Please use Search before posting and read the Manual

martin.fernau
Posts: 4
Joined: Nov 19, 2019 5:54 am

Re: opening attachments in a new window

Post 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.

Post Reply