image integration with the views module

gordon - June 5, 2006 - 01:19
Project:Image
Version:4.7.x-1.x-dev
Component:image.module
Category:bug report
Priority:normal
Assigned:gordon
Status:closed
Description

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.

AttachmentSize
views_image.inc1.93 KB

#1

gordon - June 27, 2006 - 07:36

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.

#2

mboes - June 29, 2006 - 22:55

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

#3

gordon - June 30, 2006 - 00:18

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

#4

vatavale - July 6, 2006 - 07:47

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.

#5

gordon - July 31, 2006 - 06:32

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

#6

fago - August 9, 2006 - 15:31

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?

#7

fago - August 9, 2006 - 17:02

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

AttachmentSize
views_image_0.inc 1.96 KB

#8

jake28 - August 9, 2006 - 22:34

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

#9

jake28 - August 9, 2006 - 23:36

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.

#10

gordon - August 14, 2006 - 00:07

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

AttachmentSize
image_views.patch.txt 2.94 KB

#11

gordon - August 14, 2006 - 07:54

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.

AttachmentSize
image_views.patch_0.txt 2.1 KB

#12

webchick - August 17, 2006 - 19:09
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!

#13

m3avrck - August 17, 2006 - 19:23

Works wonderfully well!

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

#14

gordon - August 21, 2006 - 05:38

Here is an example of use for the views integration.

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

AttachmentSize
snapper1156138568692.png 267.66 KB

#15

natan - August 21, 2006 - 21:57

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 -->

#16

gordon - August 21, 2006 - 23:58

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

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

#17

walkah - August 23, 2006 - 20:01
Status:reviewed & tested by the community» fixed

committed. thanks guys!! :)

#18

dodazzi - August 24, 2006 - 14:45

does this work with attached images?

#19

Tobias Maier - August 26, 2006 - 12:27

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

#20

george@dynapres.nl - August 30, 2006 - 20:10

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?

#21

schwa - August 30, 2006 - 20:31
Category:feature request» bug report

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

#22

gordon - August 31, 2006 - 00:09

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

#23

Anonymous - September 14, 2006 - 00:15
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.