Is there any way to make the hyperlink to the file be correct as soon as the file is uploaded?
I'm moving my files into a directory that's specific to the taxonomy term that the page is tagged with. So I'm using [term-raw]. I'd love for the links to the files to be correct as soon as they're uploaded, so that the user could just right-click on the icon representing the file, copy the link, and paste it into the body. Is there any way to do this? Maybe I'm just missing it.
Right now the link to the file is missing the [term-raw] until the node is saved. This forces the user to upload the file, save the node, then edit again and grab the link they need.
Comments
Comment #1
decipheredNo,
Due to the way that Drupal works, you can't have 100% of the Node tokens available until the node has been created (specifically NID, but there are others). In your very own example, if you changed the Taxonomy Term after uploading the file your path would be wrong.
There is code in FileField Paths that will search through the Node Body and any other CCK textfields to fix incorrect paths, so there is no reason why you can't do what you'd like already :)
Cheers,
Deciphered.
Comment #2
attheshow commentedSorry, I'm not sure from the description above what I should do. It sounds like you're saying it's possible, but you didn't suggest a course of action.
Comment #3
deciphered@attheshow
What I'm saying is that if you upload a file to a node, copy the link to the file and paste it into the body, while the URL will be wrong at the point of pasting it (http://yoursite.com/sites/default/files/file.ext), when you save the Node, FileField Paths will move the file, then search through the Nodes body field and do a find and replace on the old path changing it to the new path (http://yoursite.com/sites/default/files/new-path/new-name.ext).
So you don't need to do anything out of the ordinary, just do the approach you suggested and it will just work.
Cheers,
Deciphered.
Comment #4
attheshow commentedWow, I had no idea that was in the code where it's searching through the body content to see if it needs to make adjustment to links. That looks like it works splendidly.
...unless you upload a second file that has the exact same name as the first file that was moved. Some of my editors have done that in the past, so I just thought I'd check to see what happens. Here's what just happened for me:
In that situation, it looks like the behavior is incorrect. Just thought I'd point this out since I was examining the process. I'd like to mark this as a bug report at this point, but am hesitant to do so for fear of upsetting you.
Comment #6
canzi commentedIm having the same issue mentioned above
i.e. ...unless you upload a second file that has the exact same name as the first
if an update of a file is performed = delete -> upload modified file ( same name ) -> save
then all existing links have there "File path:" added again
i.e.
/dpal_redeemer/sites/default/files/test/23202_695109497_4148_n.jpg
gets changed to
/dpal_redeemer/sites/default/files/test/test/23202_695109497_4148_n.jpg
appreciate your help
Steve
Comment #7
canzi commentedhttp://drupal.org/node/859720#comment-4279122
Comment #8
decipheredNo longer supporting Drupal 6 issues for this module.