It's very convenient to be able to write a template function to modify the the options used to create the links for uploaded files. I wrote the following:
function masslegal_upload_attachments($files,$options = null) {
// all attachment links should open in a new page.
$options['attributes'] = array('target' => '_blank');
return itweak_upload_upload_attachments($files,$options);
}
Because I wanted links to open in a new window.
However - itweak_upload_upload_attachment only pays attention to the $options argument if the file is to be previewed :(.
I'm not sure why that is. I've attached a patch to change that behavior.
jamie
| Comment | File | Size | Author |
|---|---|---|---|
| itweak_upload.module.theme_.options.patch | 517 bytes | jmcclelland |
Comments
Comment #1
iva2k commentedGreat! Can community review and post results here? If there are no problems, I can commit quickly.
Comment #2
nessunluogo commentedI was looking for some solution to open attachments with target="_blank", using this great module.
So I patched the file, added the code in my template.php (changeing the name of the function, obioviusly)... and it worked like a charm.
Comment #3
iva2k commentedI looked into the patch, and found the logic that I do not fully understand:
The original logic does not pass options when user has no access permission ($file->access), and then the file either needs to have a preview, or should be an image. With new code, image files ignore file->access, and ignore empty options. In case of empty options the l() function will throw an error (this is the reason for passing array() instead of empty variable $options).
I am acknowledging that $file->access use logic here is questionable, but I copied that code from core upload module. I can propose the following code instead:
Then your custom override code can set $options['custom'] = TRUE; and options will be passed in. If there is no custom code, the original logic is preserved.
Comment #4
iva2k commentedI checked the proposed modification (...||isset($options['custom']) to 6.x-2.x-dev. I have no way to verify except that it does not break the original functionality.
Please try it (you need to modify your code to set $options['custom'] = TRUE), and reopen if it does not resolve your problem.
Comment #6
BigEd commentedHi did this ever get added to the module or is this still in a proposed patch?
I am looking for a way to open the files in TARGET = "_blank" #
Thanks
Comment #7
iva2k commentedRead #4 - one mod is in 6.x-2.x-dev as of October 2010.
BTW It's pointless to comment on an issue closed a year ago - most people won't see it with default filters.
Comment #8
BigEd commentedOk point taken i will make a new post, did think of that after i had posted lol.
Thanks for advice anyhow.