I have a node type with one common filefield for uploading both media (audio, video) and image files. Now, I wanted to create a block displaying only three random nodes which has only files of image types. In order to do that I created File type view with:

- a filter 'File: Mime type contains image' and
- a field 'Content: Photo, twi75 image linked to node' (twi75 is a name for imagecache preset)

This combination works just great and provides nice block with only images. The problem is that 'image linked to node' leads to homepage and not to the image's node.

$view = new view;
$view->name = 'three';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'files';
$view->is_cacheable = FALSE;
$view->api_version = 3.0-alpha1;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Defaults */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '3';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'grid';
$handler->display->display_options['style_options']['columns'] = '3';
$handler->display->display_options['style_options']['fill_single_line'] = 1;
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: Content: Photo, Audio or Video (field_file) */
$handler->display->display_options['fields']['field_file_fid']['id'] = 'field_file_fid';
$handler->display->display_options['fields']['field_file_fid']['table'] = 'node_data_field_file';
$handler->display->display_options['fields']['field_file_fid']['field'] = 'field_file_fid';
$handler->display->display_options['fields']['field_file_fid']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_file_fid']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_file_fid']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_file_fid']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_file_fid']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_file_fid']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_file_fid']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_file_fid']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_file_fid']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_file_fid']['link_to_node'] = 0;
$handler->display->display_options['fields']['field_file_fid']['label_type'] = 'none';
$handler->display->display_options['fields']['field_file_fid']['format'] = 'twi75_linked';
/* Sort criterion: Global: Random */
$handler->display->display_options['sorts']['random']['id'] = 'random';
$handler->display->display_options['sorts']['random']['table'] = 'views';
$handler->display->display_options['sorts']['random']['field'] = 'random';
/* Filter: File: Mime type */
$handler->display->display_options['filters']['filemime']['id'] = 'filemime';
$handler->display->display_options['filters']['filemime']['table'] = 'files';
$handler->display->display_options['filters']['filemime']['field'] = 'filemime';
$handler->display->display_options['filters']['filemime']['operator'] = 'contains';
$handler->display->display_options['filters']['filemime']['value'] = 'image';
$handler->display->display_options['filters']['filemime']['case'] = 0;

/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block_1');

I also tried to select just 'twi75 image' with no link in Fileds and checked out option 'Link this field to its node'. This way also does not work, the view provides links like http://mysite.com/node/ with not nid or node alias.

$view = new view;
$view->name = 'three';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'files';
$view->is_cacheable = FALSE;
$view->api_version = 3.0-alpha1;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Defaults */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '3';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'grid';
$handler->display->display_options['style_options']['columns'] = '3';
$handler->display->display_options['style_options']['fill_single_line'] = 1;
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: Content: Photo, Audio or Video (field_file) */
$handler->display->display_options['fields']['field_file_fid']['id'] = 'field_file_fid';
$handler->display->display_options['fields']['field_file_fid']['table'] = 'node_data_field_file';
$handler->display->display_options['fields']['field_file_fid']['field'] = 'field_file_fid';
$handler->display->display_options['fields']['field_file_fid']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_file_fid']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_file_fid']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_file_fid']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_file_fid']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_file_fid']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_file_fid']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_file_fid']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_file_fid']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_file_fid']['link_to_node'] = 1;
$handler->display->display_options['fields']['field_file_fid']['label_type'] = 'none';
$handler->display->display_options['fields']['field_file_fid']['format'] = 'twi75_default';
/* Sort criterion: Global: Random */
$handler->display->display_options['sorts']['random']['id'] = 'random';
$handler->display->display_options['sorts']['random']['table'] = 'views';
$handler->display->display_options['sorts']['random']['field'] = 'random';
/* Filter: File: Mime type */
$handler->display->display_options['filters']['filemime']['id'] = 'filemime';
$handler->display->display_options['filters']['filemime']['table'] = 'files';
$handler->display->display_options['filters']['filemime']['field'] = 'filemime';
$handler->display->display_options['filters']['filemime']['operator'] = 'contains';
$handler->display->display_options['filters']['filemime']['value'] = 'image';
$handler->display->display_options['filters']['filemime']['case'] = 0;

/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block_1');

I tested this on both 3.x and 2.x versions of Views and could not get needed links.

Comments

dawehner’s picture

Project: Views (for Drupal 7) » FileField
Status: Active » Needs review

From my perspective this is a bug of filefield. The views handler works fine.

yngens’s picture

Title: Request for Node type views to provide additional options for filtering out files according to their mime information » 'Image linked to node' in Fields does not actually link to node in File view type
Project: FileField » Views (for Drupal 7)
Category: feature » bug
yngens’s picture

Title: 'Image linked to node' in Fields does not actually link to node in File view type » Request for Node type views to provide additional options for filtering out files according to their mime information
Category: bug » feature
dawehner’s picture

Title: 'Image linked to node' in Fields does not actually link to node in File view type » Request for Node type views to provide additional options for filtering out files according to their mime information
Category: bug » feature
Status: Needs review » Active

Change back.

yngens’s picture

Title: Request for Node type views to provide additional options for filtering out files according to their mime information » 'Image linked to node' in Fields does not actually link to node in File view type
Project: Views (for Drupal 7) » FileField
Category: feature » bug
Status: Active » Needs review
quicksketch’s picture

Status: Needs review » Closed (duplicate)
yngens’s picture

Status: Closed (duplicate) » Active

quicksketch, could you please point out which issue it duplicates to. I really would like to get this solved and searching in the issue list for the Filefield could not find similar one.

dawehner’s picture

@yngens

I don't understand what you posted in http://drupal.org/node/857258#comment-3215338

If you say this issue should be deleted, it's duplicated/closed.

quicksketch’s picture

Status: Active » Closed (duplicate)

I believe that yched has said that this issue would be solved by #857278: Provide additional options to filter nodes, containing files in filefields according to their mime data, and so this issue is a duplicate.

yngens’s picture

Status: Closed (duplicate) » Active

Sorry for confusion, but I was asking to delete only comments. Let me try to explain the difference between two issues.

#857278: Provide additional options to filter nodes, containing files in filefields according to their mime data was about node type views to filter out nodes with files according to their mime data.

This issue was separated because it was about views of file types, which fail to provide correct links to the nodes associated with the respective files.

The first has been solved and I got what I wanted. Nevertheless, I am separately reporting this bug of filefield module, since dereine believes the views handler works fine and this issue is of filefield module.

quicksketch’s picture

Title: 'Image linked to node' in Fields does not actually link to node in File view type » 'Image linked to node' in Fields does not link to node in File view type
Priority: Normal » Minor

Okay, after re-reading this issue I think that the reason this formatter doesn't work is because the "node" information is not in scope. You can't link to the node if you don't know which NID the image is attached to, so in order for the "Image linked to Node" formatter to work, you need to add a relationship to the Node table first, then all the CCK formatters start working again.

As it turns out, it looks like *none* of the CCK formatters actually work unless you make a node relationship first, so I think it makes sense that we require this relationship to be added before any of the content fields become available.

I couldn't figure out how to get this working after attempting a few things, so for now the solution is simply add a Node relationship first, and then use that relationship when adding any fields from the "Content" group of fields.