I could use a hand figuring this out, as the documentation for Views 6.x API is non-existent.
This in our views.inc crashes:
/**
* Implementation of hook_views_plugins
*/
function image_views_plugins() {
return array(
'module' => 'image', // no idea, just aping what views module does
'style' => array(
'image_gallery' => array(
'title' => t('Image: Gallery'),
'help' => t('Displays image nodes as a gallery.'),
'handler' => 'image_views_style_plugin_gallery', # this crashes it
'theme' => 'image_view_gallery',
'uses row plugin' => TRUE,
),
),
);
}
/**
* Style plugin to render view as a gallery
*/
class image_views_style_plugin_gallery extends views_style_plugin {
}
The error is "Class 'views_style_plugin' not found"
Is it simply because image is processed before views (alphabetically) and views_style_plugin doesn't exist yet?
Comments
Comment #1
joachim commentedSo what's the deal with this?
Drewish suggested way back that image_gallery could go entirely Views-based, but from comments at http://drupal.org/node/21037 it seems that a lot of people don't want to have to install Views.
So I'm not sure whether it's worth working on this or not.
There's lots of open requests for more ways to sort or display images, which I think points to going with Views. Combining Views and non-Views versions of galleries in the same module for 5.x-2.x was a bit messy. I can see a case for even having two separate flavours of the module, but then general enhancements and bug fixes have to be applied in two places :/
I'd appreciate the maintainer's thoughts on the matter :)
Comment #2
icecreamyou commented+1
Comment #3
drewish commentedjoachim, i'd be into splitting them into two modules but the only problem with that is that you'd really want to share a taxonomy between them... any ideas?
IceCreamYou, not the most useful comment.
Comment #4
icecreamyou commentedYeah... I was going for motivation, not usefulness. I'm not capable of actually helping with this except for testing.
Comment #5
yesct commentedI'm confused about views support in 6.x ... in the image handbook page on creating galleries, it says views has default image gallery views ( http://drupal.org/node/207216 and I posted the same question there ) but I think that documentation / handbook page is talking about image 5.x-2.x .... ?
Comment #6
hexengon commentedi vote to incorporate views into image 6.x ...any idea if this is happening as of yet
Comment #7
AaronCollier commentedMarked #259067: Add Views 2 support as duplicate.
Re #5: Yes, that's about version 5.x as it says in the top right of the book page.
Comment #8
joachim commented> any idea if this is happening as of yet
When there is documentation that explains to me how to get it to work with Views 2!
(See http://drupal.org/node/235062, for example.)
ETA: just spotted this: http://groups.drupal.org/node/10129
Cheers drewish. Will have a look at this soon.
Comment #9
drewish commentedmarked #268048: Views compatibility as a duplicate
Comment #10
joachim commented@drewish:
I was getting a "Fatal error: Class 'views_plugin_style' not found in \sites\all\modules\image\views.inc on line 152".
Fixed it by moving my code to "image.views.inc" from "views.inc".
Does that mean the whole of the current views.inc file should be renamed?
Also, that wiki page doesn't seem to mention much about the template. Eg file name and all that. Any chance you could briefly sketch those in? I can flesh out the docs a bit more as I come to them.
Comment #11
drewish commentedcommitted the attached to HEAD. it moves the views code into .inc files.
Comment #12
drewish commentedas for how the views2 code itself should work i've got no idea. but at least now the patches will be on the right files.
Comment #13
dngpng commented@drewish, I'm currently using the Image and Views module and have this compatibility issue. Could I ask how long will it be before the functions in image.views.inc and image_attach.views.inc get converted according to Views 2's API?
Comment #14
joachim commented@dngpng: when I get round to doing it, unless someone beats me to it. Better API documentation would be an incentive. Hint hint.
Comment #15
bajakan commentedHere's a patch to the views inc file that gets you an image field for the views 2.0 module. It is very basic and only has the one field, but it's a start!
Comment #16
joachim commentedI had a problem applying this -- the second section with the class didn't take. But I'm on Windows and patch is a bit hit and miss there, so it could be my end.
The function comment needs updating: * Implementation of hook_views_tables()
And I've built a view, but the field just looks like "Image: 3" where 3 is the nid of the image node.
I'm getting duplicates too, but not consistently of all image nodes. This might be down to the presence of derivatives -- in fact it probably is; the nodes not showing several times are small images.
Comment #17
joachim commentedAlso, which version of Views 2 are you working from? I gather that merlin's changed the functions a few times.
Looking at beta 4, I suspect you may need a function option_definition() rather than function options(&$options). At least, I can't find that function in any parent classes.
Not having much joy getting option_definition to work though.
Another thing is that I think it'd be better to extend views_handler_field rather than numeric.
Comment #18
joachim commentedTry this function instead of options().
Reading the comments it looks like options() is still in there but only for backward-compatibility (to the earlier alpha releases perhaps??)
$appearances isn't getting filled. Is your intention that this will have a list of different image derivative sizes and an option for a link?
(I think I'm gradually cracking it :)
Comment #19
bajakan commentedugh yeah I'm having more difficulty also, the views aren't coming out right. I'm on Alpha 5 of views 2.0, that might be a problem for me too. I'll upgrade tonight and test it some more.
Comment #20
bajakan commentedcouldn't get the options to work, simplified it down, now just need to figure out why it prints that "image:" part before the image.
I'm on windows too, and don't think this is even "patch" quality so here is the contents of my .inc file:
---
Comment #21
drewish commentedsince this is totally broken in the current version, i'll have a pretty low threshold for committing. feel free to mark it rtbc when you two feel it's ready.
Comment #22
bajakan commentedHere is a new version, basically I'm using the Image Size field in the database as the field for the view. Then I've included two views:
* a default view that shows "My Photos", it uses the Image Size field for rendering and for filtering.
* a default view that shows images by username like http://yourdomain/images/admin
The duplicates are fixed with this also, next steps will just be more rendering options aside from the image size.
If anybody else can help test it out, it should be ready for commit.
Comment #23
bajakan commentedComment #24
drewish commentedhere's that as a patch. i'm not so sure about the new default view... joachim what are your thoughts?
Comment #25
joachim commentedI don't think showing all derivative images is right.
If people want that, they should make a 'file' type view.
For a node view, the view should show one row per node, with the image field having an option of which derivative size to show. The filter on image size isn't needed then.
I'd keep the same field name we had in 5.x, as that's been around for ages.
Comment #26
bajakan commentedI totally agree about the options. I just couldn't get them to work correctly.
So let me see if this is correct from what you're saying, make a single default view that is a node view that shows one image per row, with a set of options for which image size to show.
I left drupal 5.x a long time ago and don't remember the field names, I can change that to whatever like in the drop down how should it read?
It reads: "Image nodes: Image Size" right now I think.
I will be working more on it next week.
Comment #27
R.Muilwijk commentedImage attach views integration: http://drupal.org/node/279844
Comment #28
drewish commentedmarked #282577: No Views Implementation? as a duplicate
Comment #29
deviantintegral commentedI've applied this patch, and the good news is that it works reasonably well! A bit of feedback:
Thanks,
--Andrew
Comment #30
AaronCollier commentedMarked #306867: No Image: Display Image as a duplicate.
Comment #31
Ryanbach commentedAny update?
Comment #32
wmn commentedyes?
may the patches posted here be applied on the new version of views?
Comment #33
shrop commentedI patched the latest dev version of none of the views options or default views show up. Cleared cache too. Any ideas of what I may be missing?
Thanks!
shrop
Comment #34
wmn commentedi can confirm this.
i once had it working with the patches in this topic
is there a lot of work to be done to make image.module fully support views in drupal 6?
Comment #35
rcarvalho commentedHi there,
after trying every possible patch and instruction provided in this forum I've had no luck with getting the image module to work with views 2. Could someone give me some pointers as to what steps/patches I need to get this to work. I'm currently using drupal 6.4 on linux.
Any pointer is much appreciated!
Comment #36
joachim commentedBasically, someone needs to sit down, read the Views2 API documentation, and write the code.
I would guess the patches are too old now, and also the View2 API went through several changes over the different betas and rcs.
Comment #37
Hetta commentedmarked http://drupal.org/node/309899 as duplicate.
marked http://drupal.org/node/279844 as duplicate.
Comment #38
sampeckham commentedI'm having this issue too because of the recent change in Views API at RC2 stage.
However, I have a stable setup with the current Image module (03 Sept), and Views2 RC1.
It's frustrating though I need to update Views to fix another problem, but that breaks all my images!!
Comment #39
miiimooosubscribing
Comment #40
geraldito commentedsame situation as sampeckham: stable setup with Image 6.x-1.x-dev and Views 6.x-2.0-rc1 but updating to Views2 RC2, RC3 and RC4 breaks image attach field.
Comment #41
jonesui commentedsubscribing
Comment #42
Hetta commentedmarked http://drupal.org/node/318238 as duplicate.
Comment #43
valentino_42 commentedJust curious if this is still actively being looked in to?
I'm about to start in on a site and this is my one stumbling block.
Comment #44
joachim commentedHad a quick look at it today... a very quick look.
The problem with getting duplicates is that we have the node table on the left with nids, and the image table on the right which lists nids and images. It's always going to have several images per nid, because of derivatives.
The way this was done on 5 is to have an alias of the node table itself. I reckon the same approach should be tried for 6.
Comment #45
mark_basedow commentedI followed the instructions by KarenS at http://angrydonuts.com/attention-views-api-developers and was able to get the Image module working with the latest version of Views (6.x-2.0-rc5) quite easily.
Sorry I don't know how to make a patch for this.
First add the following to image_attach.module
and then move the image_attach_views_handler_field_iid class to its own file image_attach_views_handler_field_iid.inc.
Comment #46
sampeckham commentedThis worked for me straight away! Great stuff. Now if they would just update the Image module formally!
This Views api is causing me problems across the board.....
Comment #47
drewish commentedsampeckham, it'd get updated much quicker if there was a patch ;)
http://drupal.org/patch
Comment #48
jerror commentedMay be a stupid questions, but it's my problem right now...
After putting the code into image_attach.module i have to:
What code do i have to put into image_attach_views_handler_field_iid.inc?
and
Where can i place image_attach_views_handler_field_iid.inc?
Thx
Comment #49
mark_basedow commentedThe image_attach_views_handler_field_iid class is in the image_attach.views.inc file. Move this class to image_attach_views_handler_field_iid.inc in the same directory.
Comment #50
JThan commentedHello.
I cannot get this to work correctly.
I can select "Image attach: Attached image Attached image " as a field in Views right now, but no Image will be shown.
Here is what I have done:
Added this to image_attach.module at the very end:
Cut this out of image_attach.views.inc and added it into a new file named "image_attach_views_handler_field_iid.inc (and added the
<?phpat the beginning of the new file). So the new File looks like this:This is how image_attach.views.inc looks like now:
This is the Views SQL Code:
Can anyone please point me to the right direction? Thanks in advance.
Comment #51
prbass commented@JTHAN: It will be hard for people to help you if you post code like that.
It is much more polite to post a patch - then people will be able to see easily what you have changed.
See http://drupal.org/patch for help.
Comment #52
prbass commentedRight, I've read through this thread, and it seems to have switched contexts part of the way through.
It was wrongly marked as a duplicate of Image attach views integration: http://drupal.org/node/279844
That patch needs updating for the new Views API, as described above in #45, so I have created a patch and attached it that node for testing.
However, it would be great to expose the rest of the module to views too, which is what the initial patches in this node tried to accomplish. I'll dig into that and the Views documentation to see if I am up to updating these patches for the updated views 2 API.
Comment #53
joachim commentedThis issue is meant to be for the main image module.
To my mind, we ought to get Views support working & committed for image module first, and then get it working in the submodules.
Comment #54
Flying Drupalist commentedI say this is probably critical.
Comment #55
krlucas commentedAttached is a patch to (begin to) add Views 2 support to Image module.
Disclaimers:
--this is my first contributed patch ever of all time so be nice.
--i don't use CVS for version control so i hope i rolled the patch in a way that's actually usable
--it's been rather minimally tested
--the code probably deviates from Drupal standards in many many ways
What it does:
--adds the Views 2 API hook to image.module
--moves views.inc to a new /views directory and basically rewrites it for the new api
--creates three new class files for custom field and filter handlers
--the patch was diffed against the latest dev
Known issue:
--If the view attaches the image node to a base node via a CCK Noderef relationship, attempting to sort on any of the files table fields (filesize, filepath) throws an error.
Comment #56
SpriteGF commentedPatch on #55: This works beautifully with Views 6.x-2.1 on Drupal 6.6. I couldn't salvage my original views of my images, but at least I could re-create them and they worked!!
Many, many thanks.
Comment #57
drewish commentedkrlucas, the big things that jumps out at me is that there a bunch of whitespace problems with your code that sort of make it hard to review. drupal's coding standards (which the image module tries to follow) specify that spaces are to be used for indenting rather than tabs.
Comment #58
wmn commentedPatch on #55: i tested it, the patching went ok, but the /views directory wasn't automatically created.
i did it manually and moved all view related files.
it doesn't do what i want it to do though, i find no way of only seeing the thumbnails.. but maybe i'm overlooking something.. will try to learn from your codeEDIT: and so i did, you can just add a filter.this works for me thanks a lot!
Comment #59
schlotterich commentedI get an error when I try to patch the image.module file. Cygwin says: Hunk #1 FAILED at 1032. The other files get patched fine. I put the image_views_api function manuelly in the image.module file but I still can't see any Image Fields in Views.it works now! I just had to put the image_views_api function at the very bottom of image.module
Comment #60
schlotterich commentedgreat work krlucas! the only thing that misses for me now is a field for an image with an link to thickbox. Do you have any ideas how to do that?
Comment #61
wmn commented@schlotterich
its just a setting in thickbox i think, i did the same yesterday, but reverted it because it wasn't working the way i wanted it too.
i did a lot yesterday so sorry, dont remember how exactly. if you really have trouble figuring it out send me a message and i'll try re-enable it on my site.
Comment #62
krlucas commentedI'll look into cleaning up the code (white space, comments etc) on patch #55 so it can actually be reviewed and maybe committed. For my current project I have the views integration for Image and Image_Attach running as standalone custom modules so as to avoid any conflicts with other Image updates. Thus, there's some search and replace work for me to turn them into real patches.
Comment #63
sunCleaned coding-style and formatting. Reworked comments, and added plenty of @todos. The patch does the ground-work so far, but the actual implementation looks and feels wrong. The different fields should be just one field with an additional field configuration form to adjust the link, image size, aso.
Comment #64
drewish commentedi'm wondering if we could use relations for the various image sizes.
Comment #65
AmrMostafa commentedApplied and Tested. Comments:
Proposed extra features:
Comment #66
AmrMostafa commentedNew patch; Summary of modifications/additions:
click sortablefrom filters, removed repeatedgroupas it's inherited by default, field handlers renamed for consistency, fetching from$valuesin render() is more reliable but not tested with CCK nodereference)TODO/Doubts:
Comment #67
krlucas commentedImage base link was supposed to provide a link to the base node of the view in the case where the Image node was included secondarily via a relationship (CCK noderef for instance). For instance, imagine the base node is content type "Product" and you include the Image node via relationship. Image Base node would render an HTML image tag wrapped in an anchor tag with an href to the *Product* node, not the *Image* node. So that's that. Solved a problem for me but might be better left to the theme layer.
Anyway, I will definitely test the patch and report back. All your changes look superb.
-kl
Comment #68
AmrMostafa commentedThanks for clearing up the nodereference bit! Here is a new patch with mainly 2 new things:
Comment #69
AmrMostafa commentedAnother iteration, nothing major this time. Just minor fixes and comments. Also re-factored image field handler's
render()into smaller build units to allow other modules which work with image module to extend from this handler and override the bits they would like to extend.Comment #70
skyredwangever heard people calling you hero? anyway. does *3.path work with Image 6.x-1.0-alpha3 ?
Comment #71
AmrMostafa commenteddoh another fan.. Yes, everyone calls me by that actually :P
Seriously though, it works with alpha3 indeed. :)
Comment #72
MGN commentedThe patch in #69 applies cleanly to alpha3 and provides image:image and image:image size fields, and image:image size filter, as advertised. I was able to set up a nice view with a grid of scaled images very easily.
The only problem I had is with image links. Whether I choose "link the image to..." base node or image node, the path is set to "/node/" (see below). Linking the node title works correctly. The only problem is with the link to the image.
The problem is in the $url assignment in image_url() (image/views/image_views_handler_field_image.inc). $image_node should be $image_nid and $base_node should be $base_nid.
This fixes the problem.
Also I am curious if the class name is correct with the extra space at the end?
Coder didn't report any problems aside from small code formatting issues (Actually more problems in the original alpha3 module than in theses new views extension files).
I'll test further and report back if I see any problems. But right now, this looks excellent. Thanks!
Comment #73
AmrMostafa commentedGood catch, must be after I refactored this bit into smaller functions for extensibility. I will get another patch on, maybe with image_attach support as well.
Also, I have an important fix for a rather important issue with the way image_size is currently being added to the query is not correct. As it should be part of the join not as a WHERE. The reason is that if you are would like to get nodes with images AND others without imaging, Views2 will build the query with a LEFT JOIN. However, the WHERE clause for image_size will mean that only nodes whose images match the e.g. image_size='thumbnail' are returned. Thus, only nodes with images will be returned (which is not what the user wants). Solution? the image_size condition should be part of the join with the image table not a WHERE.
Comment #74
joachim commentedI can't get this patch to apply on a fresh checkout of HEAD: it says the views.inc (or whatever it's called) file already exists and will get deleted, assume [R]? If I delete the file, it complains it's not there... I think I've exhausted the combinations of responses I can give to patch's error messages.
Comment #75
AmrMostafa commentedSo far I've been working against alpha3, if it's not too much trouble you could try with that.
As we speak, I'm working on image_attach (for some reason I can't get it right, yet) but once I'm done I will try to generate a patch against HEAD as well :)
Comment #76
Ylan commentedThis patch really helped me out. I haven't done any extensive testing, but so far so good.
I'm looking forward to the next patch. Also this should be applied to HEAD soon, as this greatly improves the usability of the image module.
Comment #77
andypostsubscribe
Comment #78
drewish commentedyeah, alienbrain and i have been in contact about this. i'm on vacation and didn't want to commit it before i left. he was going to clean some things up and have something for me to test later this week.
Comment #79
rayray commentedI'm very excited to see this code, thanks so much. This is one of those things where you get 90+% done with your project, and then you suddenly realize there's actually no way to fit the pieces of the puzzle together. Oops!
Comment #80
Hetta commentedmarked http://drupal.org/node/332687 as duplicate.
Comment #81
tom friedhof commentedHere is the same patch as #69 with the addition of another join to the files table so you have access to the fields in the file table for the given images you are pulling.
With this patch you can access filepath, mimetype, size, etc... (All the fields in the files table)
All that was added to patch from #69 is the following code in image_views_data():
Comment #82
AmrMostafa commentedI've invested more hours recently in that patch but it appears that there is a fundamental decision that needs to be taken regarding on the approach we will take.
After raising my doubts with Earl and a bit of discussion, here is how I see the problem now:
Background
In order to display an image, we need its path which is stored in the
{files}table; We need to join to that table.Problem
Normally, we will join to the
{files}table like this:... {image} LEFT JOIN {files} USING (fid) .... But now what happens when you also add a field from the upload module. Upload module needs to add the{files}table as well which would be like:... {upload} LEFT JOIN {files} USING (fid) .... Now clearly both JOINS shouldn't exist in a single query. unless they are distinguished as relationships. Views cannot make an automatic decision as to which table (image or upload, or any other table doing the same) it should be using for joining the{files}table.Solution
There are 2 solutions, or rather approaches. Unfortunately neither is perfect.
Approach 1
We leave the choice to the user; We do that by not joining to
{files}ourselves, and relying on the user to add a relationship to the files. The relationship will include an option to choose the image size(s).Pros:
{files}base available as well (i.e. all files data like file size, mime and so on).Cons:
Approach 2
We create a new alias of
{files}, or we execute a separate query inpre_render()to get all filepaths from{files}for all images involved (Example:views_handler_field_upload_fid::pre_render) and then we don't need to join{$files}in the main query. The former is what is being done in recent patches.Pros:
Cons:
{files}. We will need to duplicate the fields of{files}in our new aliased{files}. Or;{files}pre rendering; The user won't be able to access the files data and will have to add a relationship to{files}to get the files data and then we will end up with 2 joins of{files}which could end the user up with duplicate rows.How to proceed?
What do y'all think? Feedback appreciated! :)
Meanwhile, I will see if I can provide 2 patches with the different approaches!
Comment #83
AmrMostafa commentedRegarding #81:
Actually tom, while this works for Images, it breaks
{files}for everything else. Actually, I think it's a demonstration of the Problem explained in #82.The definition you added tells Views that
{files}is always linked through{image}. And while that suits our own needs. It breaks upload module, for instance. Try this:{image}on the page nodes. Which is obviously not what you want in this case.{files}) should ideally be made through a relationship. Because then when you add "File: Name" field, the field will have an option to choose which relationship to use; In which case you can choose either Upload or Image relationship.Comment #84
skyredwangRe: #82, The Image Module is still in Alpha mode. I am wondering if there anything could be done by the module maintainer to solve the problem (as well as integrate this patch)? Your Approach 1 cons says "Not obvious ..."; think about if a user has to apply your patch in order to use Views with image, it's already not obvious enough.
Comment #85
tom friedhof commentedI like approach 1 of #82. We are already used to creating relationships with other modules, so approach 1 seems more natural and just as obvious for people that are already familiar with creating views.
Comment #86
Flying Drupalist commentedMany modules already require adding relationship. I don't think it's much of a drawback. Putting it in the instructions, as having a sampel view with the relationship is probably enough.
Comment #87
AmrMostafa commentedInteresting, can you guys point me to some modules which require adding a relationship?
Meanwhile, I'm almost done with a patch which requires a relationship, and I was planning to continue working to add a twist which allows it to fallback to the
pre_render()approach (an approach already used by upload.module, check it for details; but basically, it executes a separateSELECT ... {files} ... IN (fid1, fid2, ...etc)to get the filepaths with one separate query) ONLY if it cannot find the relationship present.Comment #88
Flying Drupalist commentedFlag and Voting API comes to mind, though I'm sure there are others.
Comment #89
AmrMostafa commentedNew patch; It requires the "Image: Files" relationship to be added.
As usual, summary of changes:
{files}. Now relies on the newImage: Filesrelationship. A notice is added when the relationship isn't present.Hint: Apply patch with
patch -p0 < image_views2_integration4.patchwhile in image module directory.Comment #90
drewish commentedcommitted part of this so i could drop the old views1 support... here's a re-roll.
Comment #91
rayray commentedJust curious, is the patch in #90 different than that of #89, or is it a successor?
I applied #89 and tried to get my views working with the image. Whenever I set up the relationship, the table would vanish; it couldn't render. Then, after a few minutes, the AJAX queries in Views crashed my database server! I'm not kidding. I went through the process twice from scratch, and each time I ended up having to reboot my (production) server!!!
Very strange. I have trouble believing this patch could be causing it, but see no other logical explanation. Weird. So be careful with this patch! I'm rolling back to the standard Views for my Drupal 6.6 setup, but will keep an eye out for future patches and give them a try.
Comment #92
nquocbao commentedWhen I applied the patch, I got this sql error :
Anyone has any idea about this ?
Comment #93
nquocbao commentedSorry, I forgot to add Image Files relationship :(
Seem like drupal is very hard to use, and quite tricky too
Comment #94
nquocbao commentedThanks to the #50 reply. I follow this and get image_attach work correctly.
I don't know how to create a patch because i'm using windows & svn. So I attach the final result. Maybe someone help me to create a patch
Comment #95
AmrMostafa commentedWell, welcome to Drupal first! :)
Requiring the relationship is indeed not the best thing.. right. But so far we cannot find a nice way around it. It's natural from a technical point of view, but yes, not the best for end users.
This is still an open issue anyway, you are welcome to participate and help make this better if you know Views2 ;)
Comment #96
AmrMostafa commentedThis patch introduces validation for the existence of the relationship when saving or previewing the view and throws a friendly error if it cannot find it instructing the user to add it.
It requires this patch to views: http://drupal.org/node/343047
Comment #97
AmrMostafa commented@rayray It would be great if you could write reproduce steps. So we could try going through the same steps and see if we can hit this. It would also be useful if you mention the versions of image and views modules you are using.
Comment #98
joachim commentedFrom comment #82:
> 1. Not obvious for end users unless special attention can be given to instructing user to do this.
This patch has to come with documentation for this. Online through the help system would be good, but also a handbook page.
Comment #99
rayray commented@alienbrain - thanks. Well, I tried the latest patch of yours, along with the Views one you reference. The integration5 patch seems to have issues with the directory referencing, so I was force to do parts by hand. I do think I did it correctly, however.
So I did get the Image reference to show up in the views I'm working on. The problem happened again: once I added a relationship from the view to the Image (thumbnail size), I saw the MySQL 5 process spike at 100%, and the preview (via AJAX) was trying to render but never did. I waited to see what would happen, but after a bit deleted the relationship and after about 10 seconds the database calmed down. Weird.
I'm running Acquia Drupal 6.6 on this server (1.03) with Views 6.x-2.1 and Image 6.x-1.0-alpha3. The server is running PHP 5.2.4-2ubuntu5.3 and MySQL 5.0.51a. It should also be noted that when I'm looking at the Content Type I'm working on, the image feature I'm looking for is under the Image Attach settings section. I say this to be sure I'm even barking up the right tree!
I'll give it one more shot here before rolling back. Thanks for all your work on these patches, I really appreciate it!
Edit: I did give it another shot, no luck. I updated my Image module to the latest dev version, which did give me this ability, but performance is simply awful! I'm not sure if there's just too many tables involved, or if I have too many issues, or if I need to address some indexing issues, or what. But it certainly appears that my problems with this might just be that we have lots and lots of legacy images on our site, and our database server just can't handle the load.
Comment #100
AmrMostafa commentedNew patch that introduces Image: Node relationship. This makes it possible to build image views starting from "files". I.e. View type "File" instead of "Node".
Comment #101
AmrMostafa commented@rayray Been using git recently and not yet used to its diff parameters. Always forget to use the right ones. The recent patch shouldn't have that problem.
Now to the main problem, I actually cannot reproduce it yet. I need more information about the View itself. Would it be possible to export your view and attach it?
Comment #102
irishgringo commentedjust to confirm... all I would really like to do is create a view of just the images in a gallery... thats all... Idealy I would like to make the galery type something like a Content type that holds nodes of images. My thoughtis that I would like tto create a slide show based on attached images... I already have that working in my own newbie way... but it seems to work.
so, is there no way to get a list of all image node images?
Comment #103
AmrMostafa commentedFor galleries, galleries are really just Taxonomy Terms. So if you want a listing of all items in a given gallery. You do the above steps, plus: Add a new filter: "Taxonomy: Term" and select the "Image Galleries" vocabulary then select the term (gallery) you want to restrict results to.
Comment #104
skyredwangalienbrain, the latest image module dev supports Views2. Have you tried it yet? however, that version doesn't work well with relationship(noderefenence)
Comment #105
AmrMostafa commentedOh oh. Not really. I checked image dev from CVS and by downloading the -dev version from the project page, but didn't find an implementation of hook_views_data() in neither. Only implementation was for hook_views_api().
Perhaps I need help with CVS! :)
Comment #106
joachim commented* Apply the latest patch (at #100).
* Create a new view of Node type.
* Add a filter of node type and select "Image" content type.
* Add a new relationship: "Image: Files". Choose the image size you want.
* Add a new field: "Image: Image".
I think this is too faffy. Getting images to show should be available out of the box.
If you look at the code for 5.x, it simply uses image module's regular function for getting an image given a node and the handler options show the sizes.
Can't we use this approach, and let users create a relationship if they want exotic stuff about their image file?
Comment #107
drewish commentedalienbrain, you're not rolling patches against HEAD so you're patches aren't applying. you probably need to CVS up your local copy.
it'd be good if when you posted an updated patch you explained what you changed so that i could compare your patch to the last patch i'd applied and make sure it's not missing any changes.
Comment #108
drewish commentedjoachim, i don't think it's unreasonable at all. go look at the date module. that's got some wacky setup but that's just what you've got to do to provide the full views capabilities. we need to provide a default view so people know how it works but i don't think we should take away the flexibility from people who might need it.
Comment #109
pillarsdotnet commentedImpossible to use "cvs diff" command to re-roll patch in #100 because it can't deal with the creation of new files.
Here is a re-roll of the patch in #100 (also using "git diff") against today's CVS HEAD checkout.
It is virtually identical to the original; the only difference being that image.module no longer needs to be patched.
Comment #110
Aaron Stanush@drupal.org commentedsubscribing
Comment #111
drewish commentedpillarsdotnet, that's incorrect CVS can deal with missing files, it cannot create missing directories how ever which is why i committed part of the patch and added the views directory. see: http://drupal.org/patch/create and http://wimleers.com/blog/cvs-diff-new-files-fakeadd
Comment #112
pillarsdotnet commented@drewish:
I copied the script from http://wimleers.com/blog/cvs-diff-new-files-fakeadd#comment-288 then switched to my sites/all/images directory and typed:
The cvs command output the following:
Still doesn't cope with new files. Any suggestions?
Typing the command "cvs --version" outputs the following:
(Edit)
Tried again with regular CVS with the same results. Running "cvs --version" now outputs the following:
Comment #113
drewish commentedpillars, fakeadd should have some output. Here's what I did to generate the attached patch.
Comment #114
drewish commentedhere's the patch.
Comment #115
pillarsdotnet commentedHmm... Tried the following:
fakeadd aborts, complaining that the CVS directory doesn't exist.
Trying again...
fakeadd outputs the following:
Running "cvs diff -upN" outputs the following:
Are you pulling from a different CVS branch than I am?
Comment #116
codeseek commentedI'm lost.
I think I've followed the directions (repeatedly) to apply the patch but I'm not seeing the Image:Files relationship or the Image:Image field.
1. I applied the patch in #114 and cleared cache
2. Created new view of type Node
3. Added filter on Node Type: Image
4. Didn't see the Image:Files relationship or the Image:Image field
5. I applied the patch located here: http://drupal.org/files/issues/views_handlers_validate4.patch
6. Created new view of type Node
7. Added filter on Node Type: Image
8. Didn't see the Image:Files relationship or the Image:Image field.
What am I missing?
I'm running views 6.x-2.1 and image 6.x-1.0-alpha3 on drupal 6.6
Comment #117
bcn commentedAttached is a copy of the latest dev version of this module with the appropriate views files included....
Comment #118
clo75 commentedHi
Tried to use "image-6.x-1.x-dev-views2.zip" with "views-6.x-2.2". Added "Image: Image" to field. Added filters "Node: Type = Image " and "Node: Published Yes "
Got this message :
user warning: Unknown column 'filepath' in 'field list' query: SELECT node.nid AS nid, image.nid AS image_nid, image.image_size AS image_image_size, node.title AS node_title, filepath FROM node node LEFT JOIN image image ON node.nid = image.nid LIMIT 0, 10 in /home/sphechr4/public_html/sites/all/modules/views/includes/view.inc on line 725.
tried also with ""views-6.x-2.1" but doesn't work
Anything wrong ? Thanks.
Comment #119
loze commentedsame here as #118
Comment #120
loze commentedgot it.
you need to add a relationship for the size image you want.
Comment #121
juliekj commented*subscribing*
Comment #122
dmetzcher commented*subscribing*
Comment #123
ppmax commented#117 views module worked for me. I deleted my old image dir then uploaded the new one containing views integration. I got the same error message posted above in #118 but it went away after defining a relationship.
looking forward to a release with views integration included.
pp
Comment #124
pildwell commentedplease, how can i add that relationship for the needed size?
Comment #125
andypostIs there a patch? What maintainers think about this longlasting issue?
Comment #126
nquocbao commentedYes, I think it's time to finalize this issue
Comment #127
bcn commentedAttached is a re-roll of the patch from #114 made against HEAD.
Comment #128
drewish commentedi don't like this code but i'm going to do a new alpha release then ahead and commit it as a starting point.
marked #357413: hooking with views2? as a duplicate.
Comment #129
drewish commentedi went ahead and committed this. grab a -dev version if you want to play with it.
Comment #130
robertdjung commenteddev version gave me an error when trying to use it in views.
user warning: Unknown column 'filepath' in 'field list' query: SELECT node.nid AS nid, node.title AS node_title, image.nid AS image_nid, image.image_size AS image_image_size, filepath FROM node node LEFT JOIN image image ON node.nid = image.nid WHERE (node.status <> 0) AND (node.type in ('image')) LIMIT 0, 10 in /var/www/sitename/sites/all/modules/views/includes/view.inc on line 725.
Comment #131
bcn commented@robertdjung: Did you create a relationship for you view? See comments #106 & #120 above.
Comment #132
nquocbao commentedDoes image_attach support view2 ?
Comment #133
robertdjung commentedaha, I had everything except the relationship. Thanks noahb. works like a charm.
Comment #134
gorcon commentedWorks well. Thanks.
Comment #135
thijsvdanker commentedI'm getting the following error message:
user warning: Column 'nid' in field list is ambiguous query: SELECT nid, node.title AS node_title,.... etc.
I'm using the field and relations as described above, anyone with a clue?
Comment #136
skyredwangCould someone compare this thread patched Views support with the out of box support from the latest dev? At least, the latest dev doesn't require relationship
Comment #137
zdean commentedI got the same error before I defined the relationship. Try deleting/redefining the relationship and see if it clears up the glitch.
Comment #138
gregorovius commentedHi. If I create a new view, add a 'page' display, and add the 'Image: Image' field, I get
user warning: Unknown column 'filepath' in 'field list' query: SELECT node.nid AS nid, image.nid AS image_nid, image.image_size AS image_image_size, node.title AS node_title, filepath FROM node node LEFT JOIN image image ON node.nid = image.nid LIMIT 0, 10 in /home/content/m/o/o/moorugs07/html/area3/sites/all/modules/views/includes/view.inc on line 725.
the query being
SELECT node.nid AS nid,
image.nid AS image_nid,
image.image_size AS image_image_size,
node.title AS node_title,
filepath
FROM node node
LEFT JOIN image image ON node.nid = image.nid
I'm using the dev snapshot from 2009-Jan-19, and I tried the patch in http://drupal.org/node/360170 without any changes.
Sorry, I hadn't read all comments, adding the relationship fixed it.
Thanks,
Comment #139
AaronCollier commentedReading the comments does help.
Comment #141
joachim commentedI wish I had time to look at this because I *really* don't like the idea of having to add a relationship just to get basic functionality.
Surely it should be possible to have it *just work* out of the box AND allow advanced users to create further relationships to get exotic data from the image or file tables.
Comment #142
Fayna commentedI was playing around with the latest Image dev version and created a view and a relationship as described in the comments above. When I added my Image: Image field, I got this error just below the "Live Preview" text in the Views UI.
user warning: Column 'nid' in field list is ambiguous query: SELECT nid, files_image__image.nid AS files_image__image_nid, files_image__image.image_size AS files_image__image_image_size, title, files_image.filepath AS files_image_filepath FROM node node LEFT JOIN image image ON node.nid = image.nid AND image.image_size = 'thumbnail' LEFT JOIN files files_image ON image.fid = files_image.fid LEFT JOIN image files_image__image ON files_image.fid = files_image__image.fid LIMIT 0, 10 in /../sites/all/modules/views/includes/view.inc on line 731.Using Views 6.x-2.3.
Edit: Just realized that when editing my Image field in the View, if I choose "Do not use a relationship" the error goes away and the images appear in the preview.
Comment #143
joachim commentedI am planning to get some work done on this this week -- however I have a cold so wrapping my head round some of the finer points of Views is proving difficult :(
I'd appreciate any help if people spot me in IRC :)
Here's what I've figured out so far:
The main issue with images is that the image table is a bridge between the node and the files tables. That is, an image can be considered as either a part of a node, or as a special kind of file.
My goal for how views support should work is this:
- node base table: add an 'image' field, pick the size in an option for this field. Further info from the file table (filesize, mimetype, etc) should be accessible on adding a relationship.
- file base table: add an 'image' field, get fields such as image display, image derivative size name. Further info such as the details of the image node should come from adding a relationship.
I reckon the way to get this to work is by aliasing the image table twice, for both node and files base tables.
I've got the derivatives in as options in the image node handler. Working on getting that data into the query as an extra WHERE clause.
Comment #144
joachim commentedHere is a patch.
It adds a fields in the image group to display the image. It's simple! Add the field, pick the size in the options, and you're done :)
For people wanting more complex data from their images, the existing stuff is still there -- eg if you want to show several derivative sizes per node, or you want the raw filepath of the image, or its filesize and so on.
Some consolidation of code might be in order in a future patch: eg, a parent class handler that holds common code for displaying images.
I've not done an image table alias for the files table base. I haven't figured this out entirely, but I reckon (again, in a future patch) we could ditch the relationship from images onto nodes, and just have the the two image aliases for files and node bases, and the relationship to get files when you're based on nodes.
Comment #145
drupal999 commentedsubscribe
Comment #146
greggus-1 commentedHello,
Thanks for your work.
I have one more question: can anybody tell me how to automagically replace default image gallery view with that one created by views? Please...
I know it must be smoething with path and arguments, but I can't figure it out.
Comment #147
irishgringo commentedI'm not sure I understand the question. are you asking for a special format of the image? you can look at imagecache for that. also, there are ways to display images in a jquery or lightbox slide show.
Comment #148
joachim commented@greggus: the next thing on my list it to create a Gallery views style... :)
Comment #149
greggus-1 commentedNever mind.
I've found the way to make image_gallery look just as I wanted.
Comment #150
seidren commentedcould you please explain how you did it ?
I am attempting the same...
Thanks.
Comment #151
timatlee commentedWould be interested in knowing how you made the galleries display as you intended.
At some point when using Drupal 5, the images were no longer sorted by node ID (or posted date). I never looked into it, thinking that I could fix it with views...
Comment #152
nstrassner commentedI have read through this entire thread, but I'm still confused regarding Image module and Views 2 integration and need some clarification.
I am trying to use the image module with views 2, but when I add to the field list, "Image attach: Attached image" (original size, no link) all I get in Live preview is the text "Attached image:" and no image. I've tried several permutations (different sizes, etc.) but no joy.
I would appreciate it if someone could shed some light on that.
Thanks in advance for some help here.
-Videoman
Comment #153
manoz_79 commented+ Subscribing
Comment #154
peterjmag commentedI'm also trying to figure this out. My problem is identical to #152 (and I'm assuming to most of the people in this thread). Have the patches in this thread already been applied to the current version (alpha4)?
Drupal 6.10 core
Image 6.x-1.0-alpha4
Views 6.x-2.3
Thanks in advance!
Comment #155
hebhansen commentedThis thread is running old. is it fair to assume that the patch is fixed in Views 6.x-2.3?
If not then the patch, where does it go?
Which Module?
Which file?
after what and before what?
What hets deleted?
I expect to have the same as 154 and 152. What is the answer to that?
There is a dev Views released 3 days after 6.x-2.3... Does that solve anything?
Comment #156
joachim commentedPatch #144 is on CVS HEAD.
I appreciate that a lot of people commenting here are implementing sites and badly need a working system, and perhaps haven't time to apply a patch and test in a non-production environment -- I know that pressure all too well!
However perhaps if you can't test the patch you could chime in with use cases? These would help maintainers decide which fields and handlers are needed. I'd like to take this forward and get it committed, but having two approaches to image fields (either automatic, or with a relationship needing to be created) is potentially confusing and I feel some streamlining is required.
Comment #157
hebhansen commentedThanks
Where is CVS Head?
Which Module?
Which file?
Comment #158
hebhansen commentedFYI
The usermanual for Image Galleries D6.x links to here. Maybe thats why a lot of newbies show up...
http://drupal.org/node/207216
Comment #159
joachim commentedReminder to self: derivs probably need to be regenerated when looking at image fields in a view.
To the newbies: if you don't know how to patch and want to try, the Drupal docs have sections on getting a CVS copy and applying the patch. Hint: the patch is on image.module :p
Roadmappy stuff: I've just had a chat to EclipseGC who is working on what may become a 6.x-2.x branch, built on top of imagefield with imagecache support. A lot of views stuff will then come for free from CCK.
Given this, my opinion is that we should aim for views support in 6.x-1.x that is GOOD but we don't need all the whistles and bells. I'd like to get my patch in (someone please test?), maybe simplify some of the relationship stuff, then move on to image attach and gallery (in other, shorter, issues!)
Other maintainers, interested parties: opinions?
Comment #160
Anonymous (not verified) commentedSubscribing.
I was linked here for my problem where I cannot for the life of me get Views 2.3 on D6 to show a block for the image_gallery. I hope this is the right place and a fix happens soon!
Comment #161
Encarte commentedsubscribing
Comment #162
joachim commentedThink I've found a problem in my patch: if the image is smaller than the required derivative size, it doesn't show.
This is not the desired behaviour -- requesting "derivative foo" means "show this derivative or the original if that's smaller" (see image_load). Or in other words, derivative sizes that are not present due to being too large fall back to the original.
(And we'll need eventual imagecache support to do that too btw).
This would suggest that choosing which file to get shouldn't be done in the views query, because I reckon it's too complex to check for an entry in the image table before showing it.
I can get the query to do this:
that will give us the fallback, but if we don't need it we'll get multiple rows, won't we?
This suggests that the handling of which image derivative to get should be done in the handler code rather than the query.
This means either doing a node_load or a cut-down node_load ans using some of the image module logic for finding derivatives.
Comment #163
joachim commentedNew patch.
As stated above, I am ditching the query-altering approach because it can't get us what we want in the case: "want thumbnail images. Image for node X is smaller than the thumbnail size, so no thumbnail image exists or can ever exist".
So this now makes a fake $node and passes it off to image module functions to get the image.
This also handles checking whether derivatives need to be rebuilt.
So nobody gets confused:
- this is a patch on image module CVS head.
- the more people test this and confirm it works, the quicker it can be committed and released
- the Drupal handbooks have pretty good instructions on how to apply patches. I was a patch n00b till recently and they've worked for me :) If you get stuck you can ask for help on IRC. People are always keen to get new testers on board. If the handbooks are unclear, you can comment on them and help improve them.
Also, if you feel that testing patches it not within your technical competencies, there isn't much point in subscribing to this issue. We know a TON of people need this. When it's committed and released, you'll see a new release of image module. Until then, I for one am finding it a bit depressing getting lots of +1s and subscribes but nobody actually testing :(
Comment #164
joachim commentedFeel free to kick me, but I'm about to change this patch AGAIN.
I'm developing a site to use image views as I go, and I found the field wasn't able to be put through a relationship. Adding it to the node table fixes that.
(The use case was: the nodes I wanted to list had a CCK noderef pointing to image nodes, and I wanted *that* image to show.)
Will upload patch tonight when I'm not at work...
Comment #165
joachim commentedNew patch. Again ;)
This adds the basic image field onto the {node} table as a pseudo field, instead of previous patch which made it global.
The advantage is that you can use this with a relationshhip, if you need to. Otherwise, it's still a simple field that you just add and don't need to configure.
So:
- simple use: just add the field and pick the size
- more complex cases: add it on a relationship. I have a tested this with a nodereference relationship.
(I'm using both these cases on a site in development).
- beyond the basic field, there's the existing views fields on {image} table that *always* need a relationship.
Ready for testing (I hope!)
Comment #166
mean0dspt commentedchecked out the latest CVS and read the patch code. it's unclear to what version the patch #165 relates, as some of the patch strings are already there.
So I'm not ready to test
Comment #167
joachim commentedPatch #165 is against HEAD.
I've just tried applying it against a totally fresh HEAD and it applies fine.
Which strings do you mean?
Comment #168
jubalkessler commentedI've applied the patch to HEAD of image, and it seems to work OK. However, I would strongly suggest that the patch's additions to the Image module be tested using contributions/modules/image/test/image.test, e.g. run a few use cases in there so the code itself is exercised programmatically. Please don't depend solely on user input.
All that said: thank you, Joachim.
Comment #169
joachim commentedThanks for giving it a try!
There are no current tests that test anything to do with views, as far as I can tell.
Comment #170
geerlingguy commentedSubscribe. (I hate subscribing when I don't have anything to contribute, but ah well).
Comment #171
Anonymous (not verified) commentedI don't get it.. It still wont work for me.
I was referred to this thread from another that was marked duplicate, where I cannot use Views + Image_Gallery to create blocks that show images from certain galleries. I tried everything, even move to CCK + Imagefield but that didn't work.
From what I saw above, the new HEAD views is supposed to have that blocks inclusion, but I still cannot find it anywhere or create it. When creating, I can only see Node that's closest, but that shows the word "Image" which links to the Image Node, rather than showing the actual Image itself in the block..
Please help. Thanks.
Comment #172
joachim commented@xushi: with the current image 6-1 alpha you can get the image field if you add a relationship first. If you apply the patch from this issue, you can get a regular image field that works more simply. You can then filter on vocabulary term (ie gallery) and add a block to your view.
Comment #173
Anonymous (not verified) commentedThanks joachim. That helps, and pardon my slowness :)
Which would you recommend, using image 6-1 alpha, or this patch? I'm currently on alpha4.
Does the current -dev snapshot include the patch? Should i use -dev since its last update is more recent?
Comment #174
joachim commentedThe current -dev snapshot will include the patch once the status here says "fixed" instead of "needs review".
We need people to test the patch to get to that stage.
Whether you use the patch depends on how much you want to much about with CVS and patching and testing ;)
Okay, since people seem confused, and given 173 comments to wade through I don't blame them:
Status of this issue
(as of date of this comment)
- the current alpha version of Image (6.x-1.0-alpha4) has no views support
- the current dev snapshot of Image (6.x-1.x-dev 2009-Mar-21) has an image field that requires a relationship to add it, either from a node view or from a file view. IMO it's overly complex for the majority of cases.
- the most recent patch in this issue (#165) is a patch on CVS HEAD. It is my attempt to provide a basic image field: you add it, you pick a size, you got an image. Before this can get committed to CVS, it needs bold and enterprising people to test it :)
Comment #175
strndy commentedNice work, it seems work OK for me (6.x-1.x-dev 2009-Mar-21).
Can you please add Image: Filename to Sort criteria ?
I would be nice.
Comment #176
skyredwangI am more confused than I used to be.
#174 says "- the current alpha version of Image (6.x-1.0-alpha4) has no views support"
However, I have been using Image (6.x-1.0-alpha4) with Views2.3 support out of box and no relationship needed. The only thing in Image (6.x-1.0-alpha4) not working is the node referenced Image cannot display.
Comment #177
joachim commentedUrg. I've just downloaded an unzipped the alpha 4 and I don't see a views folder or file for the main image.module. There's a views.inc for image_attach though. Is that what you mean?
(I'm confused myself now...)
Comment #178
skyredwangJoachim,
Yes, I am talking about image_attach working out of box for Views2.3. Am I completely off the topic here?
Comment #179
joachim commented@skyredwang: not at all, but I want to get image.module views working, and then build image_attach on top of that, using some handler inheritance if possible to simplify things.
Comment #180
greggus-1 commentedHi everyone.
I made a simple video showing how to integrate image gallery and views in case someone still has a problem with this.
I'm not a professional video maker so please be forgiving...
You can download it from mediafire: http://www.mediafire.com/file/zdc4yddn0c2/image+views.avi (34629 KB)
Tried to use youtube but image quality was not acceptable.
-- edit --
Forgot to mention: i use latest dev version (2009-Mar-23) without any patch.
I use admin_menu to simplify administration.
Comment #181
andypostPatch from #165 applies to current -dev but with
patch -p3 < ...Suppose much better to load filepath in main query but image_size already stored as option so no need to select it in image_load (except permissions check)
maybe is there possibility to alter main query with files table (default relation) so (#175) and other can sort images by file params
Another issue - option "link to node" is not working because of
image_display()which does not handle additional param as URL (link leads to uploaded file)Queries generated by view:
Comment #182
joachim commented@181 -- thanks for testing! :)
Could you specify which field you're using please? Link to node works for me with the 'Image (basic)' field.
We can't load the filepath in the main query because we need to fall back on the original size when the requested derivative doesn't exist (see comment #163). As far as I can figure out, that behaviour isn't possible with a single query.
A possible third way of doing it would be to go back to the join method from #144, but have the handler do some checking if it gets an empty result -- in which case it would go fetch the original. However, this kind of hybrid approach would break if you wanted fields that related to the file in some way -- any row that had to use this fallback wouldn't get any file data, so would have empty fields for filesize, filename, etc. Partly broken behaviour is bad.
Filefield to sort on: for that, add the 'Image (with relationship)' field, I think.
image_load() -- there is some redundancy here, agreed. image_load is what the main module uses to load images for a node. However, the gain is that we get derivative regeneration and so on for free, rather than have to create a near-copy of that function for views to use.
I suppose we could break out the common parts of image_load into another function -- provided it can be done cleanly, and not overly complicate the reading of code flow following core hooks -- but I'd rather tackle that in a future refactoring patch and focus on getting working views support into the module right now.
Comment #183
TRs-1 commentedgood information , thank`s.
Comment #184
TRs-1 commentedsdas
Comment #185
andypostToday I take a closer look to code so agree with (#163) there's a possibility that image does't exists :( suppose it's a different issue
Another side is a permissions for image node if some kind of access control used - nodes can be accessed by all users so I see 2 ways
1) Basic view - should check access by node_access() not image_load() which check only access to image sizes
2) custom view (with relation) - developer should add own filters for access
@182 tested cases - just create image-nodes then create node-view (display is fields) with filter on node_type=image and add field image (basic)
Comment #186
joachim commentedandypost:
- option "link to node" is not working: could you attach the exported view where the image field doesn't work please?
- access: I don't know how views works with node access -- that would be up to the Views module itself, or the various node access modules to provide filters.
Comment #187
sunOk. To get this done I reserved myself some time and did the following:
Definition of some common example use-cases:
1) Simple node view containing the latest images from users using the Thumbnail preset.
2) Image file view displaying image filenames along with their (node) descriptions belonging to a certain category using a custom preset.
3) (Node) View that displays all images that are referenced by story nodes based on a nodereference relationship
Current state, observations:
1)
- I have to choose between two fields, Image: Size and Image: Image. "What?!"
- Chose to go with Image: Image. "Link to Image node/Base node" - I don't understand the difference.
- Error message: "Image: Image field requires Image: Files relationship to work. Add this relationship and try again."
- Adding relationship, filter for Node: type, and sort by Node: Created
- Works.
2)
- Adding field File: Name
- Adding relationship to Image: Node
- Adding fields Node: Body (Image Node), Image: Image
- Adding filter Taxonomy: Term (Image Node)
- Error: "user warning: Column 'title' in field list is ambiguous query: SELECT files.fid AS fid, files.filename AS files_filename, node_image__node_revisions.body AS node_image__node_revisions_body, node_image__node_revisions.format AS node_image__node_revisions_format, image.nid AS image_nid, image.image_size AS image_image_size, title, nid, files.filepath AS files_filepath FROM files files LEFT JOIN image image ON files.fid = image.fid AND image.image_size = 'foo' LEFT JOIN node node_image ON image.nid = node_image.nid INNER JOIN term_node node_image__term_node ON node_image.vid = node_image__term_node.vid LEFT JOIN node_revisions node_image__node_revisions ON node_image.vid = node_image__node_revisions.vid WHERE node_image__term_node.tid = 6 LIMIT 0, 10"
- Missed to select relationship for Image: Image
- Countless duplicate view results (the same image over and over again)
- "Reduce duplicates" for term filter: No help.
- Testing "Distinct": No help.
- Now I realize: These are 5 images and I have 5 presets.
- Testing whether Image: Image Size field helps. No luck. On that note: That's a pretty senseless field.
- Fail.
3)
- Adding relationship Content: NoderefField (which is a nodereference field with multiple values btw)
- Adding field Node: Title (NoderefField)
- Adding field Image: Image, relationship Image: Files (NoderefField)
- I get some results, but those are repeating the same, multiple images
- Tried further, no luck.
- Fail.
With this patch:
0) My previous view (the only that worked) still works. :) Deleted.
1)
- Adding field "Image: Image (basic)", choosing size Thumbnail; no confusing "Link to Image/Base node", yay!
- Adding filter Node: Type, sort by Node: Created
- Works.
2)
- Adding field File: Name
- Adding relationship to Image: Node
- Adding field Image: Image (Image node)
- Wow. First time I see at least a bit of the expected output: One row for each preset of a file. Promising.
- Requiring relationship "Image: Node". Still multiple rows, but always the same size. No luck.
- Note that query basically is: "
SELECT files.fid FROM files files
LEFT JOIN image image ON files.fid = image.fid AND image.image_size = 'foo'
INNER JOIN node node_image ON image.nid = node_image.nid
LEFT JOIN image node_image__image ON node_image.nid = node_image__image.nid
" -- either the LEFT JOIN or the second JOIN on image are most likely causing the duplicates.
- Adding filter Image: Image Size (Image node), selecting the desired preset (again).
- Adding filter Taxonomy: Term (Image node), selecting desired term.
- Works! (Albeit a bit clumsy query due to the needless double-join)
3)
- Adding relationship Content: NoderefField, required
- Adding field Node: Title
- Adding field "Image: Image (basic)" (NoderefField), choosing desired image size
- Expected result.
- Works!
Duly noted:
- Patch was created from wrong directory. Pretty hard to test.
So,
BRILLIANT!
This is a tremendous improvement over what we have currently. Given the fact that only my very simple view worked with the old implementation, I dare to say that we should remove the old implementation completely. It's just cruft we need to maintain. Better remove it and try to come up with actually working solutions (in a separate issue).
Now I just need some brainpower to review the actual code.... not sure whether I'll be able to do this tonight...
Comment #188
sunNow the hard facts ;)
Please create patches from the respective project root only. Also,
diff -upfor context, please.No ASCII-art, please ;) The second line is sufficient.
Those descriptions actually gave me a clue about what those fields provide. The other "Image Size" completely failed in that (rather "Preset name").
Comments should wrap at 80 chars. Also, avoid abbreviations like
don't. The second sentence might better work as@todo.Trailing whitespace. Blank lines should be blank.
Let's rip the other implementation and by doing that also the " (basic)" suffix in here.
There should be blank PHPDoc line between the summary and description. The description should wrap at 80 chars, not before or after.
I believe the default should be IMAGE_THUMBNAIL, no?
Wrong indentation.
Oh? We are doing separate file loads for each row here? Hum... I see where you're coming from now. Let's go with that for now to provide this for the masses and tinker about other approaches (elsewhere).
Lists should start at the previous indentation level, so no extra space before - here.
In general, the comments are sometimes a bit lengthy. Do you think you can rephrase them up to the point? That would be great! :)
Two examples from above:
Comment #189
sunJust fixed the file locations so further people are able to test. :)
Comment #190
nquocbao commentedHi everyone,
I need to use views to select nodes with attached images. Is this possible on current dev version ? If not how to archive that ?
Comment #191
joachim commentedI'm going to slightly expand on the use cases:
1) Simple node view containing the latest images from users using the Thumbnail preset.
2a) Image file view displaying image filenames along with their (node) descriptions belonging to a certain category using a custom preset.
2b) Image node view displaying image filenames for a certain preset.
3) (Node) View that displays all images that are referenced by story nodes based on a nodereference relationship.
2b has just come up for a site I am developing where I want to display image nodes with link codes for pasting the images in forums: in other words, I need the filename for that image, but listing nodes as the base, not files.
With these in mind, what we need is:
1) the 'Image (basic)' field -- which will be renamed to just 'Image'. It's a node field: so for 1 and 2b it works immediately. For 2a you need the files->image nodes relationship. For 3 you need CCK's node->node relationship for that node reference field.
2. The 'Image: node' relationship, which is files->image nodes. This works fine, except that the relationship's built-in filter for image size will do *nothing* unless you select 'Require this relationship'. This is because joins are LEFT by default, not INNER. We could force this relationship to be INNER, but feasibly, a user might want to list ALL files with a field of image data. Good documentation here will help -- some help text in the relationship size options to explain what to do, I think.
3. The 'Image: files" relationship, which is nodes->files. This needs help text to explain that there is no fallback: if a preset doesn't exist (because the original is smaller) then the field will be empty.
With these, all four cases work for me.
@sun: not sure what you did for case 2! All I need to this is the 'Image: node' relationship, the filepath field, and a random node field to check it works.
I'm not sure that the 'Image size' filter is very useful -- if you want image fields on a file view, you're probably going to want the relationship. But we can leave it in with some help text to say DON'T combine it with the 'Image: node' relationship -- they both try and do the same filtering. I can imagine there are complex use cases where you'd need the image size to sort on, so let's keep that field.
So, some more work I'm going to do on the patch in addition to sun's comments:
- remove 'Image (with relationship)' field
- add help text to some of the fields
- rename the handler files to conform with the scheme described in the Views API: [module]_handler_[type]_[tablename]_[fieldname]
- a LOT of good documentation in the handbook giving these four use cases as examples.
- for theming, I think we should spoof the image field's image URL into the result so it shows up in the field's ->raw property (currently there's just a big heap of HTML in $field->content). Merlinofchaos tells me this can be done by modifying $view->content -- I'll see if this can be done not too messily.
Comment #192
HS commentedComment#9 on another issue queue seems to suggest that the current 6.x Dev release of image.module is compatible with views2.
Meaning full Image nodes or images uploaded via image.module can be used as a field in Views2.
Is this correct?
I think nquocbao's question from March 31, 2009 - 04:22 is the same as mine.
Comment #193
nquocbao commentedWe can achieve this by a filter that filter node contains / not contains attached images. But I think it's better if we use right join on field ?
Comment #194
joachim commented@Hilal: it's easier if you use the # of the comment ;)
Image attach support will come later, once support for image is in.
Comment #195
HS commentedThanks for the tip Joachim.
I have a content type called 'Image' which utilises image.module to let users upload and submit images.
Views2 will pull the full the node image, title, author info, or teaser. It wont display only the image as views field.
This is the main issue.
Comment #196
joachim commentedAnother patch.
I've added a views.defaults.inc file with two test case views:
- nodes, with images, and some data about the file with the node->files relationship.
- files, with some data about the node and the image with the files->node relationship.
Both of these sample views can be simplified by removing stuff to get the various use cases in #187 and #191.
This file is not intended to be for committing, rather it's to help with testing.
Though we could consider including example views to help users.
Major changes:
- The relationships have moved. They work the same as the relationship upload module has that goes from file to node via upload table.
- aliased the image table twice, once on files, once on nodes. This means we don't get the confusing 'image size' field on nodes, where it's pretty much meaningless.
- removed nid field on image table -- if you want the nid, get the node table.
- removed the old image field.
File changes:
- REMOVED: image_handler_relationship_node_image_file
- RENAMED: all the other handler files
I think I've covered the tidying up points sun has made, except for two:
- ASCII art: I'm following the convention in views module. See node.views.inc for example.
This and detailed comments help my sanity in reading the code, and I expect I'll be the one doing most of the maintaining here ;)
I think I've covered everything with this patch now. The major use cases all work on my test setup :)
Spoofing the image filename for the image field looks tricky -- I can't see where to insert the data -- so I'm leaving that off. It was only a nice bonus anyway.
Comment #197
andribas commentedsubscribe
Comment #198
aren cambre commentedsubscribe
Comment #199
kevinquillen commentedTHANKS SO MUCH. I have been scratching my head over this for a week now. Works perfectly for me.
Comment #200
Anonymous (not verified) commentedGuys, this still doesn't work for me :(
I've been trying for 5 months now, and I still cannot figure this out. I cannot use Views + Image_Gallery to create blocks that show images from certain galleries. I tried everything, even move to CCK + Imagefield but that didn't work. I tried the views 1.6-alpha as mentioned in #172, but that didn't work. I tried the image-dev but also couldn't figure it out. I can't find what file to patch here... I am SO confused beyond anything now to where the problem is, what version of what to use with what, and how to fix it...
Could you all *please* help me with this? I've seen other pages along with this one that say "it can be done if you use X or Y with views", but I cannot even figure out how to set the Views filter to get it to work..
Can anyone please help me with a Step By Step on what's needed to install to get this to work? And how to get the views filter configured? I would greatly appreciate it, and I know many out there will too :)
Thanks.
Comment #201
joachim commentedApply the patch in #196 to CVS HEAD.
To do this, read the instructions on patching and carry them out from the root of the image module.
If you can help test this patch and report back, please do. The sooner we get this tested the sooner it can be committed.
Otherwise, requests for support just make noise in this issue.
@ #199 -- do you mean you've tested the patch in #196 and it worked? Could you confirm?
Comment #202
sun@joachim: I'd like to commit this patch. But why did you rename all views include files? Are you in IRC?
Comment #203
joachim commented@sun: if you look in the views docs, merlin gives a standard naming scheme for handler classes. It's in views/help/api-handlers.html:
So all our handlers should start with image_, not views_.
Comment #204
sunI have committed attached patch (which is basically the same as #196, only minor clean-ups).
Since the views include files changed, and those were only available in 1.x-dev, the files are emptied now (so users of 1.x-dev don't deal with wrong files). The old files need to be removed before creating a new release -- I left a reminder in CHANGELOG.txt.
Thanks for putting so much work into this, joachim!
@all: Please test the new development snapshot (available within 12 hours) and report back in separate issues.
Comment #205
timatlee commentedJust downloaded from HEAD, and applied the patch.
Not clear on what these errors mean, but the patch seemed to apply, and seems to work :P
So far, in testing, it seems to work out quite well.
Is there anything in specific I should be testing?
Comment #206
twod@#205 You get that error because the patch was already applied to HEAD on May 1 and patch wants to know if it should undo the changes in it, so you should not apply it again.
Comment #207
joachim commentedYou should probably be testing either:
- the use cases in #191
- anything that you want to do with image module and views!
Comment #208
iNade commentedSub.
Comment #209
DjC4 commentedThis is the best thing since sliced bread.
Thank you for working on this. I've been testing it in my dev site and so far it's fantastic. I can see images in my views fields and everything is working great.
Comment #210
sunYes, thanks, joachim did an awesome job.
Closing now to kick this issue out of the open issues list.
Comment #211
summit commentedBookmarking, how to use this views support for the best please?
EDIT: I found it out myself, thanks for the great patch!
Greetings, Martijn
Comment #212
jimmb commentedHello, I tried applying the patch from comment #204 to "image-6.x-1.0-alpha4" using the instructions here and here, but it did not work. The error I got was:
This is my first patch attempt, but I'm guessing the problem is that the patch is for vsn 1.1, and the .module version is 1.282. If this is true, can someone tell me how to make this thread compatible with the current version of image.module? And if I'm wrong, can someone tell me what's going on?
Thanks for any help!
Jim
Comment #213
joachim commented@jimmb: the patch was applied in #204 above -- so you can try it out just by downloading the latest -dev release.
In general though, patches should apply to HEAD rather than an alpha. See http://drupal.org/patch/apply
Comment #214
joachim commentedSetting back to closed.