i want to open attach file in new tab . but it is not working on click.

Comments

berdir’s picture

Category: task » support
Priority: Critical » Normal
Status: Needs work » Active

This is not a critical task.

mahi.orai’s picture

then tell me how to open a attachment in new window

mahi.orai’s picture

then tell me how to open a attachment in new window

monish_deb’s picture

Although it works in content edit page where clicking on attachment opens it in new window, but not so in case of view.

CowTownFarmBoy’s picture

Have you checked the permissions?

monish_deb’s picture

There are two ways to implement the changes for attached file in content view by adding the below code before return in file/file.module(function theme_file_link() ) :

1) To open file in new tab
$options['attributes']['target'] = '_blank';

2)To open file in new window

$options['attributes']['target'] = '_blank';
$options['attributes']['onclick'] = "window.open(this.href, 'filePreview','toolbar=0, scrollbars=1, location=1, statusbar=1, menubar=0,resizable=1,width=500,height=550');return false;";
mahi.orai’s picture

where we write this code.

monish_deb’s picture

Add the above code under Drupal Core module Path:"[Your Drupal directory]/modules/file/file.module" at Line : 746, function:theme_file_link() before "return".

dddave’s picture

Assigned: mahi.orai » Unassigned
Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Just wanted to add a thank you to monish_deb for the answer to this post. Helped me out today.

shraddha404’s picture

Hello

Thank You monish_deb for the solution.
You saved my days.

Shraddha
Carving IT Pvt. Ltd.

parvateesam’s picture

Version: 7.15 » 8.8.x-dev
Assigned: Unassigned » parvateesam

will have to add patch for drupal 8.8.x as well. This is not working drupal 8 as well.

parvateesam’s picture

Assigned: parvateesam » Unassigned
StatusFileSize
new647 bytes

Adding patch for 8.8.x