Hi, I'm trying to show a table of people (users) - image, name, email, phone. That type of thing. I've found the default profile image to be not 'ideal' so I've created my own image field under the user profile to upload and display this image. I also have a default image that I have assigned (which is viewable in individual profiles). This profile picture fails to get picked up by the view that I've created to list the people.

CommentFileSizeAuthor
#12 990554.patch1.1 KBbojanz
#6 990554.patch1.16 KBbojanz
#1 klein.jpg26.76 KBdcor
no_default_pic.jpg34.61 KBdcor
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dcor’s picture

FileSize
26.76 KB

picture of profile in above case...

dawehner’s picture

The problem is the following code:


  function render($values) {
    if (isset($values->_field_data[$this->field_alias])) {
      // Prepare arguments for rendering based on the objects cached in the

If there is no database result the rendering will be skipped.

dawehner’s picture

Is this still an issue?

idiotprayer’s picture

I am experiencing this issue as well. For users that don't have pictures, the view is rendered with the link to the user "Username's picture".
There also doesn't seem to be a way to set image styles on user pictures.

dgastudio’s picture

same problem, in image field, the default image is set, but in views doesn't appear.

bojanz’s picture

Status: Active » Needs review
FileSize
1.16 KB

There also doesn't seem to be a way to set image styles on user pictures.

That's a different problem, see #1029704: Add an UI for formatter settings on user picture.

As for the issue at hand, my only guess is the patch attached. Try it.
As far as I can see, we need imagefield specific code, there's no generic field mechanism for this.

Of course, the patch is too crude for commit, but if it works for people, we have a start.

dboulet’s picture

Title: Default image does not appear in User type view » Default image for image field does not appear in views
Status: Needs review » Needs work

Patch no longer applies and is, as bojanz said, a little crude.

Can anyone jump in here and suggest a good fix for this?

AgaPe’s picture

also interested

ben kuper’s picture

Title: Default image for image field does not appear in views » Default value for empty field does not appear in views

I'm pretty sure it's not just the image. I experienced this behavior with other types like text.
From what i saw, i think it has to do with this line (548) of views_handler_field_field.inc (in views/modules/field)

   if (empty($entity->{$this->definition['field_name']})) {
     // ** there should be here something to verify if there is a default value for this field
      return array();
   }

The field_get_default_value could be interesting, but i don't know how to get the $instance parameter at this place.

ben kuper’s picture

As a side note, the version 7.x-3 alpha1 works, but the views_handler_field_field.inc is really not the same.
I may have said something wrong about the code above, because the similar part in the alpha1 version doesn't handle the default_value there.

AdroAdro88’s picture

+ subscribing

bojanz’s picture

Status: Needs work » Needs review
FileSize
1.1 KB

Let's try this. It's a real patch! :)

EDIT: Of course, it fails when the field table join is made (since there's no row to actually display). It only works when there's no join.

dboulet’s picture

Patch works well for me. Not sure what is meant by "only works when there's no join".

bojanz’s picture

Try to add a filter on the field. The table gets added to the query. No field value == no row.

dboulet’s picture

Isn't that the desired behavior?

reglogge’s picture

subscribing

bojanz’s picture

Probably. In any case, we can't really avoid it. Feel free to RTBC this, and we can get it in :)

bojanz’s picture

Status: Needs review » Reviewed & tested by the community
dawehner’s picture

Status: Reviewed & tested by the community » Fixed

You can't RTBC your own patch ;)

Commited to CVS and GIT.

ben kuper’s picture

Status: Fixed » Needs review

Hi,
i'm on the latest cvs version and this is not working for me.
I got a basic setup with a term view, the terms have a image field with a default image (that i can see well in the term pages), but the view doesn't show the default images. the empty field text in empty field behavior is showing well...

ben kuper’s picture

Status: Needs review » Fixed

Oups sorry for that, it seems i got mixed up with other fields, or a cache problem...
It's working well !

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

bluestarstudios’s picture

Status: Closed (fixed) » Needs review

Hmm. I'm running the latest dev and this doesn't work. I can't see the default values for a (select) list field I created. Do I need any patches with the latest dev to make it work?

dawehner’s picture

Status: Needs review » Postponed (maintainer needs more info)

Update status. Needs review means that there is a patch available to fix the issue.

It's kind of hard to help you here. Take care that you cleared some caches. If this does not help perhaps try to reproduce
it on a new clean system and explained detailed how to reproduce it.

Then it's probably fixed in some minutes but the time until then can need quite some time.

bluestarstudios’s picture

Here are the steps to reproduce.

1. Create clean Drupal 7.8 install
2. install following modules: Chaos Tools (7.x-1.x-dev), Views & Views UI (7.x-3.x-dev).
3. Create New Content Type "My-Content" (Admin -> Structure -> Add...)
4. Create 3 nodes of "My-Content" type.
5. Go back into Structure->Content Types. Manage Fields for "My-Content". Create new field called "my_field" of type: "List (text)" -> "Select List". Add "Allowed Values List" to read:

1|Option 1
2|Option 2
3|Option 3

Make the field required and set "DEFAULT VALUE" to "Option 2".
5. Create 3 more new content nodes of "My-Content" type, in each selecting a new option in my select menu.
6. Create a new VIEW. Table with fields "Title" & "my_field". You should see all 6 nodes you created. However "my_field" values will be visible only in the 3 newest nodes. The ones that were created before the field existed will display empty values instead of the default value.

bluestarstudios’s picture

Status: Postponed (maintainer needs more info) » Active

I've posted step by step instructions to recreate. I'd really appreciate your help in fixing this. Thanks!

bluestarstudios’s picture

Status: Active » Fixed

In the end it seems that it's the way CCK in core works by default. Adding a new field doesn't add any value to existing nodes. I managed to solve this issue otherwise following this video:
http://www.commerceguys.com/resources/articles/217
Sharing it in hopes that it might help somebody else in the future.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

seaneffel’s picture

Status: Closed (fixed) » Needs work

I'm still seeing this trouble as described in the original post. I've got a view of users that calls the user picture field that links back to user accounts. Users who have pictures return nicely formatted pictures that link. Users without pictures turn up no result. I'm forced to use the "no results behavior" rules to call the default user picture directly, but then I have to noodle with the code to get that default picture to link back to the user account.

What's a default picture for if not for showing up when user pictures are called, right?

Anyway, here is a paste of my view so you can see it or try it yourself. No dependencies on other modules, pretty clean view here so I'm sure you'll see the trouble when you compare the two displays.


$view = new view;
$view->name = 'users_browser';
$view->description = 'User profiles browser grouped in various ways.';
$view->tag = 'migrated, user, profile';
$view->base_table = 'users';
$view->human_name = 'users_browser';
$view->core = 0;
$view->api_version = '3.0';
$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['title'] = 'Profiles';
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = 25;
$handler->display->display_options['style_plugin'] = 'grid';
$handler->display->display_options['style_options']['columns'] = '5';
$handler->display->display_options['style_options']['fill_single_line'] = 1;
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: User: Name */
$handler->display->display_options['fields']['name_1']['id'] = 'name_1';
$handler->display->display_options['fields']['name_1']['table'] = 'users';
$handler->display->display_options['fields']['name_1']['field'] = 'name';
$handler->display->display_options['fields']['name_1']['label'] = '';
$handler->display->display_options['fields']['name_1']['exclude'] = TRUE;
$handler->display->display_options['fields']['name_1']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['name_1']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['name_1']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['name_1']['alter']['external'] = 0;
$handler->display->display_options['fields']['name_1']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['name_1']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['name_1']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['name_1']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['name_1']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['name_1']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['name_1']['alter']['trim'] = 0;
$handler->display->display_options['fields']['name_1']['alter']['html'] = 0;
$handler->display->display_options['fields']['name_1']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['name_1']['element_default_classes'] = 1;
$handler->display->display_options['fields']['name_1']['hide_empty'] = 0;
$handler->display->display_options['fields']['name_1']['empty_zero'] = 0;
$handler->display->display_options['fields']['name_1']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['name_1']['link_to_user'] = 0;
$handler->display->display_options['fields']['name_1']['overwrite_anonymous'] = 0;
$handler->display->display_options['fields']['name_1']['format_username'] = 1;
/* Field: User: Picture */
$handler->display->display_options['fields']['picture']['id'] = 'picture';
$handler->display->display_options['fields']['picture']['table'] = 'users';
$handler->display->display_options['fields']['picture']['field'] = 'picture';
$handler->display->display_options['fields']['picture']['label'] = '';
$handler->display->display_options['fields']['picture']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['picture']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['picture']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['picture']['alter']['external'] = 0;
$handler->display->display_options['fields']['picture']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['picture']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['picture']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['picture']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['picture']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['picture']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['picture']['alter']['trim'] = 0;
$handler->display->display_options['fields']['picture']['alter']['html'] = 0;
$handler->display->display_options['fields']['picture']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['picture']['element_default_classes'] = 1;
$handler->display->display_options['fields']['picture']['empty'] = '<a href="http://localhost:8888/users/[name_1]"><img width="178" height="178" alt="" src="http://localhost:8888/sites/all/themes/icateens/images/noprofile.png"></a>';
$handler->display->display_options['fields']['picture']['hide_empty'] = 0;
$handler->display->display_options['fields']['picture']['empty_zero'] = 0;
$handler->display->display_options['fields']['picture']['hide_alter_empty'] = 0;
$handler->display->display_options['fields']['picture']['link_photo_to_profile'] = 1;
$handler->display->display_options['fields']['picture']['image_style'] = '178x178';
/* Field: User: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'users';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['label'] = '';
$handler->display->display_options['fields']['name']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['name']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['name']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['name']['alter']['external'] = 0;
$handler->display->display_options['fields']['name']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['name']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['name']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['name']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['name']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['name']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['name']['alter']['trim'] = 0;
$handler->display->display_options['fields']['name']['alter']['html'] = 0;
$handler->display->display_options['fields']['name']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['name']['element_default_classes'] = 1;
$handler->display->display_options['fields']['name']['hide_empty'] = 0;
$handler->display->display_options['fields']['name']['empty_zero'] = 0;
$handler->display->display_options['fields']['name']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['name']['link_to_user'] = 1;
$handler->display->display_options['fields']['name']['overwrite_anonymous'] = 0;
$handler->display->display_options['fields']['name']['format_username'] = 1;
/* Sort criterion: User: Last login */
$handler->display->display_options['sorts']['login']['id'] = 'login';
$handler->display->display_options['sorts']['login']['table'] = 'users';
$handler->display->display_options['sorts']['login']['field'] = 'login';
$handler->display->display_options['sorts']['login']['order'] = 'DESC';

/* Display: No Default Pictures */
$handler = $view->new_display('page', 'No Default Pictures', 'page_1');
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Field: User: Picture */
$handler->display->display_options['fields']['picture']['id'] = 'picture';
$handler->display->display_options['fields']['picture']['table'] = 'users';
$handler->display->display_options['fields']['picture']['field'] = 'picture';
$handler->display->display_options['fields']['picture']['label'] = '';
$handler->display->display_options['fields']['picture']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['picture']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['picture']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['picture']['alter']['external'] = 0;
$handler->display->display_options['fields']['picture']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['picture']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['picture']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['picture']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['picture']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['picture']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['picture']['alter']['trim'] = 0;
$handler->display->display_options['fields']['picture']['alter']['html'] = 0;
$handler->display->display_options['fields']['picture']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['picture']['element_default_classes'] = 1;
$handler->display->display_options['fields']['picture']['hide_empty'] = 0;
$handler->display->display_options['fields']['picture']['empty_zero'] = 0;
$handler->display->display_options['fields']['picture']['hide_alter_empty'] = 0;
$handler->display->display_options['fields']['picture']['link_photo_to_profile'] = 1;
$handler->display->display_options['fields']['picture']['image_style'] = '178x178';
/* Field: User: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'users';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['label'] = '';
$handler->display->display_options['fields']['name']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['name']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['name']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['name']['alter']['external'] = 0;
$handler->display->display_options['fields']['name']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['name']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['name']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['name']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['name']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['name']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['name']['alter']['trim'] = 0;
$handler->display->display_options['fields']['name']['alter']['html'] = 0;
$handler->display->display_options['fields']['name']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['name']['element_default_classes'] = 1;
$handler->display->display_options['fields']['name']['hide_empty'] = 0;
$handler->display->display_options['fields']['name']['empty_zero'] = 0;
$handler->display->display_options['fields']['name']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['name']['link_to_user'] = 1;
$handler->display->display_options['fields']['name']['overwrite_anonymous'] = 0;
$handler->display->display_options['fields']['name']['format_username'] = 1;
$handler->display->display_options['path'] = 'user_browser2';

/* Display: Yes Default Pictures */
$handler = $view->new_display('page', 'Yes Default Pictures', 'page_4');
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Field: User: Name */
$handler->display->display_options['fields']['name_1']['id'] = 'name_1';
$handler->display->display_options['fields']['name_1']['table'] = 'users';
$handler->display->display_options['fields']['name_1']['field'] = 'name';
$handler->display->display_options['fields']['name_1']['label'] = '';
$handler->display->display_options['fields']['name_1']['exclude'] = TRUE;
$handler->display->display_options['fields']['name_1']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['name_1']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['name_1']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['name_1']['alter']['external'] = 0;
$handler->display->display_options['fields']['name_1']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['name_1']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['name_1']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['name_1']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['name_1']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['name_1']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['name_1']['alter']['trim'] = 0;
$handler->display->display_options['fields']['name_1']['alter']['html'] = 0;
$handler->display->display_options['fields']['name_1']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['name_1']['element_default_classes'] = 1;
$handler->display->display_options['fields']['name_1']['hide_empty'] = 0;
$handler->display->display_options['fields']['name_1']['empty_zero'] = 0;
$handler->display->display_options['fields']['name_1']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['name_1']['link_to_user'] = 0;
$handler->display->display_options['fields']['name_1']['overwrite_anonymous'] = 0;
$handler->display->display_options['fields']['name_1']['format_username'] = 1;
/* Field: User: Picture */
$handler->display->display_options['fields']['picture']['id'] = 'picture';
$handler->display->display_options['fields']['picture']['table'] = 'users';
$handler->display->display_options['fields']['picture']['field'] = 'picture';
$handler->display->display_options['fields']['picture']['label'] = '';
$handler->display->display_options['fields']['picture']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['picture']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['picture']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['picture']['alter']['external'] = 0;
$handler->display->display_options['fields']['picture']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['picture']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['picture']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['picture']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['picture']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['picture']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['picture']['alter']['trim'] = 0;
$handler->display->display_options['fields']['picture']['alter']['html'] = 0;
$handler->display->display_options['fields']['picture']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['picture']['element_default_classes'] = 1;
$handler->display->display_options['fields']['picture']['empty'] = '<a href="http://localhost:8888/users/[name_1]"><img width="178" height="178" alt="" src="http://localhost:8888/sites/all/themes/icateens/images/noprofile.png"></a>';
$handler->display->display_options['fields']['picture']['hide_empty'] = 0;
$handler->display->display_options['fields']['picture']['empty_zero'] = 0;
$handler->display->display_options['fields']['picture']['hide_alter_empty'] = 0;
$handler->display->display_options['fields']['picture']['link_photo_to_profile'] = 1;
$handler->display->display_options['fields']['picture']['image_style'] = '178x178';
/* Field: User: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'users';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['label'] = '';
$handler->display->display_options['fields']['name']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['name']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['name']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['name']['alter']['external'] = 0;
$handler->display->display_options['fields']['name']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['name']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['name']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['name']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['name']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['name']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['name']['alter']['trim'] = 0;
$handler->display->display_options['fields']['name']['alter']['html'] = 0;
$handler->display->display_options['fields']['name']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['name']['element_default_classes'] = 1;
$handler->display->display_options['fields']['name']['hide_empty'] = 0;
$handler->display->display_options['fields']['name']['empty_zero'] = 0;
$handler->display->display_options['fields']['name']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['name']['link_to_user'] = 1;
$handler->display->display_options['fields']['name']['overwrite_anonymous'] = 0;
$handler->display->display_options['fields']['name']['format_username'] = 1;
$handler->display->display_options['path'] = 'users_browser';

seaneffel’s picture

PS, I'll say this. If you have the same trouble, then import my view from #29 above and try my trick for working around this until the real fix comes down the tubes eventually.

dawehner’s picture

Status: Needs work » Fixed

#1442470: User profile picture styles doesnt work. shows you what you probably have configured wrong.

There are actually multiple issues which explains that: http://drupal.org/project/issues/views?text=default+picture+views&status=7

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.