Here is a piece of code which will allow users to add images to tables of list views.

Required the upload include which is here.

Comments

gordon’s picture

The dependancy of #67262 as now been commited, so you only need to put this into views/modules to test.

When it is commited I recommend that this code is included within the image module.

mboes’s picture

It doesn't do anything for me. Aren't Image: fields supposed to appear in the list of possible fields?
I have upload and image modules enabled, and copied the attached file to views/modules/.

Mathieu

gordon’s picture

Views does a lot of caching, so once you have copied this into views/modules and cleared the cache you will then see that new image fields

vatavale’s picture

I create block in Views and it return error:

user warning: Unknown table 'files' in field list query: SELECT node.nid, node.title AS node_title, node.changed AS node_changed, files.filepath FROM node node LEFT JOIN term_node term_node ON node.nid = term_node.nid WHERE (term_node.tid IN ('17')) LIMIT 0, 1 in D:\work\market\sites\test\includes\database.mysql.inc on line 120.
gordon’s picture

The views_update.inc is now in views so it should work, without any changes.

fago’s picture

works fine, however one has to enable the upload module, so that views includes the views_upload.inc. that shouldn't be so... perhaps views should include content of views_upload.inc always as this stuff belongs to file.inc?

further shouldn't be this a patch against image module? or will views ship with definitions for contrib modules too?

fago’s picture

StatusFileSize
new1.96 KB

ah I forgot, there was a little problem with the display of images as link. (wrong paramters for l(), $html needs to be true..).

I've attached a corrected file

jake28’s picture

This is an awesome patch. Thank you. Is there a way to include image attach in this?

jake28’s picture

I think I can be clearer, actually. Okay, in views the image content type must be selected for this to work. But what about story, or blog content types? When they have images attached?

It would be wonderful to have this work for any content type, even cck. Thank you again for the contribution.

gordon’s picture

StatusFileSize
new2.94 KB

Images that are linked to blogs or other node types are not linked via the database, but by a img tag in the content.

This only works on image nodes.

Here is an intergrated patch for the image module that included this functionality directly into image. This will work with 4.7 but links will not work on HEAD bcause of http://drupal.org/node/78399

gordon’s picture

StatusFileSize
new2.1 KB

I have made some changes, and I have managed to add in an option on the display field you can select the size that you want to display.

The good thing about this is that if your parameters for image sizes have been changed it will create the new size on the fly, and it has made the filter redundent, so the patch is smaller.

It also no longer requires the views upload integration.

webchick’s picture

Status: Needs review » Reviewed & tested by the community

This looks ready to me. I created a couple views with this and works as expected. The ability to select between showing a previews, thumbnail, and original size image and image/link to image is a very nice touch!

m3avrck’s picture

Works wonderfully well!

I just created a simple gallery in 2 min. This is *perfect*. Please commit :-)

gordon’s picture

StatusFileSize
new267.66 KB

Here is an example of use for the views integration.

In actual fact I am using the this to develop the complete image gallery.

natan-1’s picture

Well I think i installed the patch correctly as i now have an Image: Display Image choice on the Add Field menu. So I tried setting up a test view with all images I have uploaded. First I selected a table view and then selected the "Image: Display Image" and "Node : Title" fields to display. Then for my filter I picked "Node:Type" and selected images. My list only provides me with the titles and no images show up this is my pertinant source code it I took off the rendered view page.

<!-- begin content --><div class='view view-gallerylist'><table>
 <thead><tr><th id="view-field-node_title" class="view-cell-header"></th><th id="view-field-image_nid" class="view-cell-header">Image</th> </tr></thead>
<tbody>
 <tr class="odd"><td class="view-field view-field-node_title"><a href="/?q=node/40">k</a></td><td class="view-field view-field-image_nid"></td> </tr>

 <tr class="even"><td class="view-field view-field-node_title"><a href="/?q=node/41">jk1</a></td><td class="view-field view-field-image_nid"></td> </tr>
 <tr class="odd"><td class="view-field view-field-node_title"><a href="/?q=node/43">jhnk</a></td><td class="view-field view-field-image_nid"></td> </tr>
 <tr class="even"><td class="view-field view-field-node_title"><a href="/?q=node/44">Untitled image</a></td><td class="view-field view-field-image_nid"></td> </tr>
 <tr class="odd"><td class="view-field view-field-node_title"><a href="/?q=node/45">Untitled image</a></td><td class="view-field view-field-image_nid"></td> </tr>
 <tr class="even"><td class="view-field view-field-node_title"><a href="/?q=node/46">Untitled image</a></td><td class="view-field view-field-image_nid"></td> </tr>

 <tr class="odd"><td class="view-field view-field-node_title"><a href="/?q=node/47">Untitled image</a></td><td class="view-field view-field-image_nid"></td> </tr>
 <tr class="even"><td class="view-field view-field-node_title"><a href="/?q=node/48">Untitled image</a></td><td class="view-field view-field-image_nid"></td> </tr>
 <tr class="odd"><td class="view-field view-field-node_title"><a href="/?q=node/49">Untitled image</a></td><td class="view-field view-field-image_nid"></td> </tr>
</tbody></table>
<div id="pager"><span class="pager-list"><strong class="pager-current">1</strong><a href="/?q=gallerylist&amp;page=1" class="pager-last active" title="Go to page 2">2</a></span><a href="/?q=gallerylist&amp;page=1" class="pager-last active" title="Go to next page">next ›</a><a href="/?q=gallerylist&amp;page=1" class="pager-last active" title="Go to last page">last »</a></div></div>

<!-- end content -->
gordon’s picture

This looks like it is accessing nodes which have no images.

Can you submit your view, so I can take a look.

walkah’s picture

Status: Reviewed & tested by the community » Fixed

committed. thanks guys!! :)

dodorama’s picture

does this work with attached images?

Tobias Maier’s picture

no, only with image nodes (node-type: image)

mo6’s picture

The patch redefines function image_views_tables(). Somehow my php5 installation doesn't like that and Drupal returns a blank page. I have to comment out the same function in the image.module to make it work. Am I missing something? Anyone else tested this contribution with php5?

schwa’s picture

Category: feature » bug

I installed in views/modules and upon refresh, site returned:

Fatal error: Cannot redeclare image_views_tables() (previously declared in /home/apache/htdocs/xxxx/modules/image/image.module:341) in /home/apache/htdocs/xxxx/modules/contrib/views/modules/views_image.inc on line 9

gordon’s picture

You need to remove the original views_image.inc that I posted.

Anonymous’s picture

Status: Fixed » Closed (fixed)