Using [inline_upload|file=1] when I've uploaded a single image file does not work. I get "not found: 1"
I stepped through with eclipse debugger and found where it's tripping up. inline_upload.module line 70:
if (is_int($params['file']) && isset($params['#node'])) {
70 if (isset($params['#node']->files[$params['file']])) {
$params['file'] = $params['#node']->files[$params['file']]->filename;
}
}
Looking at the variables I have $params['#node']->files[12] set, but not $params['#node']->files[1]
Looking at the database, 12 is the fid for the uploaded file. Using [inline_upload|file=12] shows the image correctly. It seems that the index it is looking for is off.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | inline-HEAD.numeric.patch | 1.02 KB | sun |
| #2 | inline_upload.module.fix-attach-id-reference.patch | 1.84 KB | Bryan76 |
Comments
Comment #1
Bryan76 commentedConfirmed. It appears that node_load builds the node in such a way that the files array $params['#node']->files does not use a sequential index. Instead it uses the uniqe fid from the drupal_files table as an index.
I have an idea or two on how to handle this.
Comment #2
Bryan76 commentedI have made a patch that "corrects" this issue. It may not be coded to drupal standards, so use at your own risk, but maybe it can be a starting point.
One thing I did is add an additional parameter "attachid". I didn't like the idea of using the file parameter to mean either a filename or a numerical attachment offset. In my mind it should only be one thing. So I made it an optional parameter and added an additional one.
[inline_upload|file=filename.jpg|title=Some Text]
-or-
[inline_upload|attachid=1|title=Some Text] (uses the first attachment. Attachment numbering starts at 1)
Comment #3
sunThanks for reporting, reviewing, and testing! Committed attached patch to 2.x.
A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.