I wanted more flexibility in the browser, paging, more control over filters and sorts, etc. The logical solution is to use views for the browser since anyone can adjust the view themselves to cover their particular needs.
Attached is a patch to add this in (the patch is not against a current version, but it is a simple patch that should not be hard to adjust). I'm also attaching the default view, which would be added as a separate file in the includes folder. The default view file needs to be renamed to remove the .txt extension.
The default view finds all imagefields and adds them to the default view automatically, sorts by creation date descending and adds paging and ajax support so it will work in the popup window, and displays it in a grid. I figured that basic view is enough for the module to include, users can then adjust the view to add other filters and sorts, change the number of items per page, or whatever.
| Comment | File | Size | Author |
|---|---|---|---|
| #33 | imagefield_assist-613968-views_1.patch | 8.3 KB | presleyd |
| #10 | imagefield_assist-613968-views.patch | 8.45 KB | franz |
| #6 | imagefield_assist-613968-views.patch | 8.4 KB | franz |
| #1 | imagefield_assist.views_default.inc_.txt | 3.95 KB | karens |
| imagefield_assist.views_default.inc_.txt | 3.95 KB | karens |
Comments
Comment #1
karens commentedOops, one mistake. We don't want multiple value fields to be grouped, we need to see all of them. Use this default view instead.
Comment #2
karens commentedDidn't mean to mark it reviewed and tested, hit the wrong item :)
Comment #3
franzHey, thanks for all that work, really appreciated!
Rerolled the patch to current -dev version. KarenS, when you want to add new files, use 'cvs diff -N -up' ;)
Alas, I still have some points:
1) I reckon you wanted to leave some room for flexibility, but the empty default view is not user-friendly at all, because you'd have to manually configure items in the view using views_ui. Not sure how this could be improved, but perhaps an unfiltered view checking for an image_field of some sort...
2) I can't go ahead of displaying the thumbs, they have to be images linked to something? How did you set up the view for it?
Again, thank you for this powerful feature, hope to see it mature soon!
Comment #4
karens commentedThe default view, as it is set up, does everything exactly the way the current code does it, so you get that behavior with no additional work. It looks for image fields and adds them to the view, etc. You should not have to do anything for it to work, it is all in the default view. It works perfectly out of the box for me. Did you clear the views cache to get a fresh view?
Comment #5
karens commentedAlso, if you have altered it, you are no longer seeing the default view. If you see an option to 'revert' the view on the views list page, you have altered the view. Revert it, clear the views cache, and then it should automatically find the right image fields and content types for the view.
Comment #6
franzGotcha: I was using Imagefield_crop (for testing the other issue)
It turns out that if_crop uses a different widget, so I changed file includes/imagefield_assist.views_default.inc from this:
if ($field['widget']['module'] == 'imagefield') {to
if (substr($field['widget']['module'], 0, 10) == 'imagefield') {and it worked. I'm not sure if this is the best solution, but it seems fine, since it will cover any widget from modules with names starting with imagefield.
Comment #7
karens commentedThat should work fine, but you might go one step further and check if either the module name or the widget name start with imagefield in case there is some foobar module creating an imagefield widget (since widgets can be created by any module). There could still be modules that create imagefield widgets that don't use imagefield in either the module or widget name, but there is no foolproof way to find them. Checking both the module name and the widget name is probably as much as we can do automatically.
Comment #8
karens commentedEr, I meant to say check if the widget name *contains* 'imagefield', to cover something like a foobar module creating a widget called 'foobar_imagefield_fancystuff'.
Comment #9
franzI agree, this probably covers almost all possiblities. The check turns into:
Comment #10
franzForgot to attach the new patch
Comment #11
sgriffin commentedimagefield 6.x-3.2
views 6.x-2.6
The view results in pages, but is completely blank for each field.
Tried patched inc and original inc, cleared views cache for each.
Comment #12
sgriffin commentedRan the query manually. It does work, but I had 25 or so fields at the beginning that were filled the NULL which is why it appeared to be blank so we just need to filter those.
Or perhaps its just my particular site but I don't think so, I created a new content type and new imagefield, added a new node with no imagefields and ran the query and pulled a record for that node.
Comment #13
franzI think that's the issue with using views for querying fields ATM that lourenzo spoke of earlier.
What the view is doing is to filter content types which have the imagefield and display thoes fields. However, they might be empty, as you have experienced, and that turns out to be an undesired output.
Maybe this can be solved with a query alter. Any ideas?
Comment #14
sgriffin commentedUsing "WHERE" ala views filter.
The only thing I found was
Configure filter Content: photo (field_photo) - list
= TRUE
seemed to do the trick.
Comment #15
franz.glauber commentedNo, that won't work on situations where you have more than a field inside a Content Type, and one of them is empty.
Actually, I think this could cause trouble on more situations, unless you have only one imagefield in the whole site.
Comment #16
andyf commentedHi, just wanted to mention I'm using the patch from #10 with beta3, and so far so good! Will let you know if I have any issues. Thanks for your work.
Andy
Comment #17
kristi wachter commentedJust a reminder for testers who experience a blank popup after applying the patch: do clear your Views cache. It may help. (Site Building -> Views -> Tools tab -> click Clear Views' Cache .)
Comment #18
kristi wachter commentedI've applied the patch in #10, and I'm having 2 issues:
* I don't see any exposed filters on the default view. Should I? Or do I have to add those myself? (Makes sense that I would have to add them ...)
* After applying the patch, whenever I insert an image, it always inserts the same one (fid=20). It doesn't matter which image I click; the same image always appears in the Imagefield Assist thumbnail display, and it always inserts fid 20.
Drupal 6.15
Imagefield Assist 6.x-1.0-beta3
Views 6.x-2.8
Thanks!
Comment #19
karljohann commentedSubscribing
Comment #20
jehu commentedPatch failed:
i've installed imagefield_assist-6.x-1.x-dev
some hints?
Comment #21
karljohann commentedI get the same. Did you solve this?
Comment #22
franzI believe it is because it was already commited...
Comment #23
jehu commented@franz
no, there is now changelog for adding view and i can find no code for the view in the module.
Comment #24
kirilius commentedIs there any date set for adding Views support to an official release?
Thanks!
Comment #25
franz@Jehu
It wasn't commited (I didn't find that on the changelog as well)
The code has change a lot, so the patch needs to be rerolled...
Comment #26
paul@poetsma.nl commentedsubscribing
Comment #27
Bryan76 commentedsubscribing
Comment #28
bibo commentedSubscribing.
Having views support or not will decide if I use this module or some other.
Comment #29
paul@poetsma.nl commentedWhat do you have in mind?
Comment #30
kirilius commentedI second "bibo" above. People don't just dump images in random ImageFields. They usially organize them in galleries. And what better way to browse through a set of galleries than Views? In a multi-user site with each user posting many images, it is absolutely critical to be able to select "images that belong to this or that user", "images that are newer than ..." or any other arbitrary criterion. All these things are easily done using Views and a nightmare to support without Views.
Comment #31
bibo commentedI think I'm going for imagebrowser. It was originally build for image-module, but the 6.x-2.x-dev branch seems to be having to have some kind of filefield & imagefield support, and it's actively worked on (I think).
At least the module UI, functionality and flexibility seem to be what I need. I haven't tested the latest dev yet, but I think it's views-layer allow (or will allow) for any image-type files to be browsed and inserted via a wysiwyg plugin. Going to test this properly in the coming days.
More info:
http://drupal.org/node/366072
http://drupal.org/node/507242
Here's also a (incomplete but decent) listing of similar image inserting modules:
http://groups.drupal.org/node/21639
Comment #32
bibo commentedOk, my opinion now after a very short testing phase with the new imagebrowser-module (2.x-dev):
Go with it! Works great out of the box with all and any images :D!
Comment #33
presleyd commentedI've rerolled against the above patch against the latest dev version (2010-Jul-11).
Unless I'm mistaken, ImageBrowser does not allow you control the upload path nor does it have the ability to allow manipulation of the image after upload (changing it from the left to the right, or setting a different imagecache preset, etc). With Imagefield going into core in D7, I think this module is the way WYSIWYG inserts will go. Views support (with KarenS and franz's patch) vastly improves this module. (Exposed filters to search through images = dead useful!)
I've tested this and don't have any problem so far. From reading above it looks like the problems have only been with rolling the patch against updated versions so it would be great to get this rolled in! Hopefully this update will help move that along?
Comment #34
presleyd commented@franz
btw what was the purpose of removing command to delete the imagefield_assist_count variable during uninstall? I left it in the patch because you had but I didn't see what purpose it served.
Comment #35
presleyd commentedAh crap I spoke too soon, as pointed out in 18, no matter which image you select from the view it always returns the first one to the WYSIWYG editor. I'll look into this.
edit: K, it's something wrong with the default View. The way it creates relationships but doesn't uniquely name them seems to be to blame. The fid just isn't filled in so it picks the first one by default. I cleaned up the relationships to just use the one Imagefield type I had designated for this (the ifa_upload type that comes with this module) and it works fine now.
I'll see if I can fix the default that it creates, that should be pretty easy.
Comment #36
dashton commentedI rolled the patch into the module and reinstalled the module, but the view is not getting generated. I'm using views 2.6, so I imagine there isn't an API problem, the .inc file shows Views 2 as the
$view->api_version = 2;but I'm not sure why the view is not generating. Any ideas? I am working on making it by hand, so if I could get an export dump from views that would be even better.Searching with views would be super useful - that's the functionality I'm looking for. Thanks presleyd for submitting this patch. I think this will be great when it truly works out of the box.
Comment #37
presleyd commentedDid you uninstall the module or just disable it and reenable it? I've used it on 3 sites now and it's always generated for me.
Comment #38
paskainos commentedsubscribing
Comment #39
lance.gliser commentedTagging. Starting to test patch now.
Comment #40
lance.gliser commentedHere's some of my initial observations.
Love that you loop over and find every imagefield and setup the default view that way. It's a fantastic way to get up and out the door immediately. But, what happens when people drush down an entire site with modules? The specialized relationships required, and the double content field requirements as well, wont' exist. I understood how this worked because I reversed the existing stuff. We'll need heavy documentation to show people how to add different field associations later. I don't think it would be out of the question to drupal_set_message with a warning that the view will need updated (and a link to the handbook) when people add a new field of type imagefield.
Without changing settings, I see some odd behavior on the preview of the view. It's by default setup for 4 columns. I set those 4, but every column, contains every picture. Every picture in a column links to the same image. The link generated, includes divs that wrap every picture.
-.field-content
--.field-item field-item-1 (Image #1)
--.field-item field-item-2 (Image #2)
--.field-item field-item-3 (Image #3)
The solution for this was to off group multiple values.
I'm seeing empty
And, I may be loosing my mind. But I don't have the view pulling up in the WYSIWYG assist.
Comment #41
crea commentedSubscribing
Comment #42
unc0nnected commentedSubscribing
Comment #43
kirilius commentedCan the patch above be rolled in a release please? I am not a Linux user and can access my site admin only through cPanel so applying a patch is not an option for me. Thank you!
Comment #44
sgriffin commentedTry using another operating system then.
http://drupal.org/node/60179
Comment #45
kirilius commentedThanks, but I noticed the patch works if applied to a Jul 11, 2010 dev version. The current dev version is from Feb 25, 2011. Who knows what changed in the meantime...
In fact is there a reason for the patch not being rolled into a release?
Comment #46
lourenzo commentedAdded to 6.x-1.x branch, tagged as 6.x-1.0-beta4 and released.
I've tested, and everything seems to be working well, please let me know if any problems happen.
Comment #47
kirilius commentedThanks a lot, I'll test now...
Comment #48
kirilius commentedWorks very well, thank you very much!
Comment #49
lourenzo commentedI thank you too, and all users.