I searched for this, but couldn't find it anywhere, so sorry if it has already been mentioned.

When adding a new file to a filefield using AJAX, when the new file information comes back with the mime-type, filesize, and the filename as a link to the file, the link should have a target='_blank' attribute, so that when users click on the link, they don't loose all the data they may have changed in the form.

I might look at creating a patch for this if there is no reason this is not added. Is it just a matter of adding the attribute in theme_filefield_file()?

CommentFileSizeAuthor
#5 filefield_preview_link.patch990 bytesquicksketch
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

Thanks, I was thinking the same thing actually, though I'd probably like to see it be a JavaScript click event instead of a target="_blank". A lot of people get upset about non-xhtml compliance. It'd probably be pretty easy to add this to filefield.js, or possibly we should just do it inline so it's easier for users to change (but then it'd effect all files, even not in the node edit form, which probably isn't good).

cdale’s picture

JS click event is probably fine, as its only really an issue when doing AHAH anyway, as that's the only time you could 'loose' information in the form. And as for only being on the node-edit form, my use case is actually outside of the node-edit form, so I'd prefer it if it was universal somehow. I think this should still be achievable with a click event though, even if it means adding another class, but I'd probably like to avoid that if I could.

cdale’s picture

I just re-read your post I realized I read it backwards from what you said. :)

So you feel it's a bad idea to affect filefields outside the node edit form? Why is that probably not good? Could we make this a programmed option somehow?

quicksketch’s picture

Yes I meant we'd only want to affect the node form. In my experience, the node form is where this is a problem, because leaving the page will loose any uploads you've done with JavaScript. Outside of the node form, I think it become a matter of preference what people will want to do. Some people will want the file to force download, some people will want it in the same window, and others will want the popup (and sometimes at a certain size). Of course for all of these you can simply override theme_filefield_file() and then you can get exactly what you want. However I think the user accidentally leaving the node form is a serious danger that could lead to frustration, so it'd be good to at least accommodate for that by default.

quicksketch’s picture

Status: Active » Fixed
FileSize
990 bytes

This patch adds popup functionality to the node edit form. It does not affect the normal node display of files. If you'd like to make the normal file display use popups, then you should override theme_filefield_file() or add some similar JavaScript to your theme.

Status: Fixed » Closed (fixed)

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