Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It would be very nice if you could flush all images from a preset attached to a single node via the Rules Module.
Comment | File | Size | Author |
---|---|---|---|
#16 | filefield_get_apis.patch | 5.84 KB | quicksketch |
#15 | filefield.patch | 1.27 KB | mikeytown2 |
#14 | filefield_get_node_files.patch | 1.44 KB | quicksketch |
#13 | filefield.patch | 2.23 KB | mikeytown2 |
#12 | filefield.patch | 2.4 KB | mikeytown2 |
Comments
Comment #1
mikeytown2 CreditAttribution: mikeytown2 commentedCreate an action that allows one to flush the node's pics on update. Comes in handy when you use node data in the pic; thus when the node changes, the pic needs to change as well.
Comment #2
mikeytown2 CreditAttribution: mikeytown2 commentedFirst Step: How do I get an array of all pics that are connected to a node?
CCK?
Comment #3
mikeytown2 CreditAttribution: mikeytown2 commentedThis gives an array of all files that are connected to that node
EDIT: give an hierarchical array to include type & fid
Comment #4
dopry CreditAttribution: dopry commentedThere isn't a patch to review here... please restated your issue or proposal and write a proper patch.
Comment #5
mikeytown2 CreditAttribution: mikeytown2 commentedBeing able to grab all the files that are attached to a node is quite handy.
http://drupal.org/node/374202
I thought that this code belongs in FileField.
Comment #6
mikeytown2 CreditAttribution: mikeytown2 commentedhmmm new site isn't liking attachments right now
Comment #7
mikeytown2 CreditAttribution: mikeytown2 commentedor editing posts...
Comment #8
quicksketchHey mikeytown2, not sure if you're still interested in this or not. I think it'd be useful to include such an API function in FileField, especially for all those people that think the content_fields() function is just too scary and can't find a way out of the simplicity of Image module's $node->image method of checking for images.
However, there will need to be some changes before this API function is acceptable:
- It should be part of field_file.inc, so it should probably be something like
field_file_node_files()
.- It shouldn't be specific to getting filepaths, rather we should just return the whole file row, right now it's odd the function is called "*_get_paths_*" but returns much more than that.
- The current approach is inefficient, instead of doing individual selects, a JOIN would be better.
- This function should have the flexibility to limit itself to an individual field, rather than always targeting all fields.
- Please just attach the patch rather than posting right in the issue
I hope we can get these changes into FileField, like I said, I think it'd be very helpful for developers trying to get off of Image.
Comment #9
mikeytown2 CreditAttribution: mikeytown2 commentedOK cool, thanks for the input. Sorry for the ugly above, this was posted hrs after the d.o 6.x upgrade. Might be a week or 2 with my schedule, will do the join optimization last most likely.
- Nuke 2nd loop, replace with JOIN in first loop.
- SELECT * FROM files would grab [fid, uid, filename, filepath, filemime, filesize, status, timestamp] throw that into the sub-array.
- Optional $field variable in order to grab an individual field.
- Renaming the function to field_file_node_files() sounds like a good plan.
Anything else?
Comment #10
quicksketchThat's all I can think of at the moment. Thanks for taking this on!
Comment #11
quicksketchI've been looking over the field_file.inc file and I realized this new function should not be placed in there. In fact, the
field_file_references()
function shouldn't be in there either. That file is meant to be the public APIs for file handling. There's no mention of anything CCK or FileField specific in the entire file (other than field_file_references).So let's keep this in filefield.module.
filefield_node_files()
should do.Comment #12
mikeytown2 CreditAttribution: mikeytown2 commentedComment #13
mikeytown2 CreditAttribution: mikeytown2 commentedworking on the join. one of the added benefits of the join is I can include nid & vid in the array; which is helpful when the nid is not passed. also forgot the filemime. Do you see anyway to simplify the
//get cck info
code block; I have some repeating code in there still.Comment #14
quicksketchHow does this look? I made the first parameter $node instead of $nid (and made it required) since I found that we can be more efficient by only getting the fields that apply to a specific node type. I also did the filtering based on the $node->vid, to reduce the duplicate rows. This also means that this function will only retrieve the current files attached to a node and not all previous revisions.
Comment #15
mikeytown2 CreditAttribution: mikeytown2 commentedhere's my take on your patch. for anyone else following this thread, call this function like the last one via
filefield_get_node_files(node_load($nid));
Comment #16
quicksketchI generalized the approach used here so we could use it for #380200: Get node referencing a file also. I've combined both these issues into a single patch which is attached. The signature is still the same, but now it can accept both a field array (if you've already loaded it) or just the field name.
Comment #18
sinasalek CreditAttribution: sinasalek commentedI tried to apply your patch but it couldn't it says :
I'm using 3.1, any idea?