I'm working on a patch to provide Views support for the Image assist browser. This is a report on the progress so far.
Completed stuff:
- Created a Views row style plugin which shows nodes as thumbnails, IA style.
- The thumbnail browser in IA is replaced by a view which uses the built-in grid type. (This view can be tweaked by administrators.) This is implemented with the same page callback as before, only now it embeds a view instead of building its own queries etc.
- The view respects the user's choice between My images, All images and taxonomy terms.
Remaining stuff:
- Provide a default view for the image browser (currently I'm using a custom view for testing).
- Add support for choosing custom views that should be used in addition to the default one. This will happen on the settings page.
- Include unpublished images in "My images". (This is the current behaviour in IA.)
- Replace the COUNT queries (used in menu texts like My images (5)) with Views magic. (Not sure how to do this with Views 2.)
- Update the css and remove any styling that has been made redundant.
I'll be back with a patch.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | img_assist-282184-exposed_filters-080722.txt | 1.05 KB | zoo33 |
| #9 | img_assist.views_.patch | 21.62 KB | sun |
| #7 | img_assist-282184-css-080718.patch | 981 bytes | zoo33 |
| #6 | img_assist-282184-views-080718.patch | 20.93 KB | zoo33 |
| #5 | img_assist.views_.patch | 21.09 KB | sun |
Comments
Comment #1
zoo33 commentedAnother thing: I suggest we remove the setting Maximum number of thumbnails per page since that can be changed in Views now. And I think few people change this anyway.
Comment #2
zoo33 commentedOK, here we go...
The attached patch does most everything outlined above, except providing the ability to add your own views to the thumbnail browser. I thought it would be best to finish the groundwork first and wait for comments – the rest will be trivial.
A few other things remain:
– Showing unpublished images in My images. This is a little tricky as Views doesn't provide a Node: published argument, only a filter. Can we lose this feature? Do people use it? (If not, I think the solution would be to define two separate displays for the default view.)
– Haven't touched any CSS yet.
A note for people who read the patch: I have changed the path scheme from:
img_assist/thumbs/xxxxto:
img_assist/thumbs/{view_name}/{arg1}/{argN}Happy reviewing!
Comment #3
sunI gave this a try as well as a thorough review - works seamlessly, even with pre-existing images from 6.x-1.x, which is even better! :)
Noteworthy changes in attached patch:
$view->hide_admin_links = TRUE;to prevent admin links from showing up in thumbnail browser. However, this will only work for IA's default view, so we probably need a tweak for other views.To display also unpublished images, we would just have to remove the whole 'status' array key from the overridden views filters ( - tested). However, I would suggest to rather leave it as is, since I would not expect images to show up (anywhere) if they are unpublished.
Some other thoughts:
Please note that I've committed some code/documentation clean-ups to all 2.x branches (shouldn't affect this patch).
Comment #4
sunNote for later (and likely another issue):
- Almost all invocations of module_exists() (regarding Image and Views) can be removed - if someone manages to disable one of both or both modules while IA is enabled, that'll be not our fault.
- Current code cries for img_assist.admin.inc and img_assist.popup.inc.
Comment #5
sun- Added views selection in admin settings.
- Added module update to remove img_assist_preview_count variable.
Last patch for tonight.
Comment #6
zoo33 commentedLooks good, works great! Made a couple of small changes:
– Views selection showed an empty row if the view title wasn't set. Added a fallback to $view->name.
– Why 3 x 3 images? 6 images (3 x 2) has always been the default, right? Changed back for now.
Thoughts:
– Should we use t() in img_assist.views_default.inc?
– img_assist.views_default.inc is indeed very large, it's a full view export. I'm not sure what parts are required and what can be removed so I would have to remove stuff piece by piece and see if it still works. I noticed that for instance comment.views_default.inc contains a full view export too. Maybe we should leave it as it is.
#3: I think using files as base table would be a little complicated with IA's current connection to Image module, since each image is represented by an arbitrary number of files. Keeping track of different sizes would be tricky too, no?
#4: Agreed. Let's restructure to .inc files after this is done.
Comment #7
zoo33 commentedHere is a separate patch for img_assist.css – don't want to clutter the main patch with even more changes.
First, let me point out that the IA window looks completely different depending on if you use it with TinyMCE or not. With TinyMCE, we get only TinyMCE's css file and img_assist.css. Without TinyMCE, IA includes all the regular Drupal CSS files including the theme's files – and then img_assist.css. (This is the intended behavior, take a look at theme_img_assist_page().)
In this patch:
– Removed unnecessary declarations.
– Hided .views-admin-links. (This is first and foremost needed with TinyMCE.)
– Added overrides for table styling. Garland for instance adds borders and margins to it's tables which doesn't work well here.
– Centered tables and node forms with margin: auto since we removed
<div align="center">from the markup.Comment #8
sunLet's commit the views patch now. Is there anything else to consider for img_assist_update_6200() ? For example, when someone updates to 2.x, how can we ensure that Views is already installed + enabled? Will Drupal handle this?
Comment #9
sunAttached patch disables IA, if Views module is not enabled during update 6200. Initially I wanted to automatically enable Views if it was available but not enabled, but I think that we are "not allowed" to stuff like that.
Since this was the only change, I'll commit this patch now.
Comment #10
zoo33 commentedGreat stuff!
How about the css patch in #7?
Comment #11
zoo33 commentedExposed filters in custom views don't work properly. When you submit the form you get redirected to a Views callback instead of Image assist, hence losing all its specific theming etc. This patch rewrites the #action attribute.
Also snuck in another fix: The Browse select list had an incorrect default value, which meant that most of the time the default would be My images, but it could also be a custom view. However, regardless of this, the bottom frame is always populated by My images by default. (This happens in img_assist.js.) So this patch sets the default to My images.
Comment #12
sunWorks, committed!
Comment #13
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.