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.
I needed to be able to reference all images, even if they are initially uploaded to another field, so I adapted filefield_source_reference_get_files (reference.inc -line 175) as follows: add $field = NULL; after the function declaration.
Is there a better way of handling this? Or is there some hidden settings i'm missing?
Comment | File | Size | Author |
---|---|---|---|
#23 | all_fields_option-454982-23.patch | 2.6 KB | Liam Morland |
#21 | all_fields_option-454982-21.patch | 2.68 KB | kpaxman |
#17 | 454982-a.patch | 2.95 KB | ezra-g |
#8 | 454982.patch | 2.97 KB | ezra-g |
#6 | 454982.patch | 2.97 KB | ezra-g |
Comments
Comment #1
quicksketchThere aren't any settings yet, but I agree that referencing any file from any field would be a good option to have. It should be an option in the future once we have a place to put these settings.
Comment #2
sinasalek CreditAttribution: sinasalek commented+!
If i understand correct The following code allows only files uploaded by filefield fields. as long as i know Drupal6's uploads files already have FID, so what's the reason for this limitation?
Thanks
Comment #3
quicksketchWe will not be able to support any file. It needs to be uploaded by a FileField somewhere. The reason for this is that FileField is the only module that keeps a reference count explaining where a file has been used. Say we referenced a file provided by upload module or a user's profile picture. Then that node were deleted that contained the reference. Now suddenly the file would be deleted even if it were in use in another location. This has been corrected in D7 with the new File API, but it will never be possible in Drupal 6.
Comment #4
sinasalek CreditAttribution: sinasalek commentedThanks for the respond,
I see, so it's Drupal's limitation actually. Is there any workaround,patch for this? or is there any discussion for Drupal6 going on?
Comment #5
ezra-g CreditAttribution: ezra-g commentedWith quicksketch's endorsement of this feature in #1, I started working on implementing this and the related configurable options for FileField_sources. I need to refactor some of the code I've written before it's fit to post here, but my approach was to make it possible for each available source to expose it's own configuration options that get aggregated into filefiled_sources' implementation of hook_widget_settings_alter() . In the attached screenshot, you can see the widget settings and the "Referencable Fields" options. I hope to post a patch later this week.
I posted in this issue rather than #436174: Configuration Options because the feature described here is my objective, and configurable options seem like a requirement for that. I could split these into two patches if quicksketch prefers.
Comment #6
ezra-g CreditAttribution: ezra-g commentedThought I hit preview...Here's the patch.
Comment #7
ezra-g CreditAttribution: ezra-g commentedIndeed I had hit preview...
This above patch makes it possible to configure which fields are referenceable. It depends on the patch at http://drupal.org/node/436174#comment-2288226 .
What's particularly exciting about referencing uploads from other fields is that it allows users to implement images as their own distinct content type with a single value ImageField, but still embed those images inside of other content.
Here's what it looks like:
Comment #8
ezra-g CreditAttribution: ezra-g commentedThis minor re-roll corrects the spelling of "Referenceable" in the interface.
Sorry for the mail flurry.
Comment #9
quicksketchezra-g! Looking fantastic. Just what I'd been hoping to do also. I'll get some free time to review your patches shortly, in the mean time keep plowing ahead. :-)
Comment #10
ezra-g CreditAttribution: ezra-g commentedThanks for the positive feedback!
Just wanted to mention that I've written a lengthy tutorial including filefield_sources, and that this module will likely come up in a presentation at DrupalcampNYC this Saturday. I'd love to be able to tell folks, "This is available now" :).
Comment #11
mrfelton CreditAttribution: mrfelton commentednothing to add... just tracking the issue so that I know when it has been committed. Great work @ezra-g
Comment #12
David Lesieur CreditAttribution: David Lesieur commentedTried the patch. Did not find the settings. Got the following PHP message: warning: Missing argument 3 for filefield_source_reference_settings() in sites\all\modules\filefield_sources\sources\reference.inc on line 66. Apparently the $widget argument is never set.
Comment #13
ezra-g CreditAttribution: ezra-g commented@David Lesieur Did you apply the dependency patch at http://drupal.org/node/436174#comment-2288226 as mentioned in #7? If so, can you describe how to generate the error you're experiencing?
Comment #14
David Lesieur CreditAttribution: David Lesieur commentedOops, that's right, I had missed that. I now get the settings and things seems to be working as expected. Sorry for the noise!
However, I'm getting this message after adding a filefield: warning: Invalid argument supplied for foreach() in includes\form.inc on line 1205. This only happens when no referenceable fields have been checked.
Comment #15
David Lesieur CreditAttribution: David Lesieur commentedAnother issue with the patch is that the "FileField Sources" widget settings are displayed for all types of fields, not just FileFields.
Comment #16
onesimpleman CreditAttribution: onesimpleman commentedThe patch works , but there is no way to get rid of the default Upload option.
I am working on a project where the only option needed is Remote URL.
Is there a work around to change the default option to Remote URL . I can hide the upload option with CSS.
Comment #17
ezra-g CreditAttribution: ezra-g commentedI found that the most recent patch no longer applied. I will upload a revised patch shortly at #436174: Configuration Options to address the feedback raised by David Lesieur in #15.
@David Lesieur: I'm not able to reproduce the error message you mentioned in #14. Could you let us know if it happens with the latest set of patches in this and the above mentioned issue? Thanks for the testing!
Comment #18
ezra-g CreditAttribution: ezra-g commentedI'm marking this as a duplicate of #436174: Configuration Options. Please see http://drupal.org/node/436174#comment-2430824 for the reasoning and latest patch for this feature. Thanks!
Comment #19
TCRobbert CreditAttribution: TCRobbert commentedI was looking into this functionality. And found it here. Checking the other issue though it seems that this functionality never made it. Any chance we will be able to see this in the future. Or am I seriously overseeing something.
Comment #20
kpaxman CreditAttribution: kpaxman commentedI would like the same functionality in the D7 module. I see a lot of talk around this that seems to have been abandoned years ago. Is there a plan for this somewhere I'm missing?
Comment #21
kpaxman CreditAttribution: kpaxman commentedIn absence of other options, I created this patch against 7.x-1.8 which gives a seemingly working "search all file fields" option, if nothing else.
Comment #22
Alan D. CreditAttribution: Alan D. commentedI've been using this for a small project where I have done all of the data entry ~60 pages, ~20 shared files, and no issues. Great enhancement imho, I never realised that this was limited till I actually needed to use it for the very first time in a real project (developer not a content author), and instantly hit this limitation on the first file! ;)
Comment #23
Liam MorlandReroll.
Comment #24
dman CreditAttribution: dman commentedThanks for the patch. Works perfectly for me today.
I'd long forgotten that I'd been using a patched version on a much older site. Funny this great small feature has been left out for such a long time.
My task today is to let an editor upload (optionally) different images for use in thumb/teaser/banner/promo and full views of an article, for various artistic reasons. So in the first instance, that's a number of filefields for them. Though I anticipate that MOST of the time they will actually be re-using the same pic, so don't see the need to force them to upload the same thing thrice, at all.
filefield_sources was my obvious go-to, but I tripped at the first step until I came and found this was still an issue.
Comment #25
bgilhome CreditAttribution: bgilhome commentedI've added an incremental feature/patch to list a thumbnail alongside autocomplete results - option in widget settings to select an image style (or none).
Comment #26
GiorgosK#23 works as designed
please commit
@bgihome while this is a great feature this issue is not about this
so I suggest you open up a new issue and post your patch to be considered
Comment #27
GiorgosK#25 patch is irrelevant to this issue
as already mentioned should be included in a new issue
Comment #28
ttkaminski CreditAttribution: ttkaminski commentedFYI, I created a new issue #2415393: Reference autocomplete thumbnails for patch in #25.
Comment #29
Alan D. CreditAttribution: Alan D. commentedIt is an awesome feature that I'd love to see get in. Anyone recently reviewed this (against dev)?
One of the few default patches left that we add to our client sites, so we nearly have a completely patch free default system 4 years into D7 life cycle... :)
Comment #30
DamienMcKennaComment #31
DamienMcKennaClosed a duplicate: #2279369: Why does Reference Existing source only select images from the same field?
Comment #32
DamienMcKennaClosed a duplicate: #2008476: File from another node's field.
Comment #34
profak CreditAttribution: profak as a volunteer commented#23 works fine and pushed to 7.x-1.x.
Thanks everyone!
Comment #35
profak CreditAttribution: profak as a volunteer commentedIn 7.x-1.10.
Comment #36
Liam MorlandThanks.
Issues should be left at status "Fixed". After 2 weeks with no comments, they will change automatically to "Closed (fixed)".
Comment #37
profak CreditAttribution: profak as a volunteer commented@Liam Morland
Thank you for your point!
Comment #38
jenlamptonFollow-up: https://www.drupal.org/node/2557461
Comment #39
Alan D. CreditAttribution: Alan D. commented#2557461: [UX] Options for "Search all file fields" are unclear
@jenlampton
if you wrap # issue number in sq brackets, this embeds the issue title and status, as above. [#number]
Removes the need to navigate to the thread to see if there is anything there of interest :)