5

I have a view in Drupal 7 that lists people (users). It shows the username and the standard user picture field. If a user has a set image, it comes through perfectly. However, for users that didn't set a profile image no image is shown, even though I have a default profile image set in the people settings for the site.

How do I get views to use the default profile picture for people that do not have a profile image set?

Update: I wasn't clear. I know how to use the default image in the no results behavior. The issue is that I can't get the default image to use the imagestyle I use for the other images.

2 Answers 2

3

Grab the path on the default image setting. Head over to your view and click on your image field. Look for "no results behavior". In the text area add

Verify that your view does not have hide if empty checked.

Save your view.

7
  • I should have been more clear. I know how to do that (and tried it). The problem is I can't get the image to pass through image cache to get the right size outputted.
    – Justin
    May 22, 2012 at 15:30
  • How many of these are you doing? Would it make sense to cut the image yourself and link to it? Or are you using many instances in different sizes? May 22, 2012 at 16:36
  • Yah, for this view just the one reduced size. I went ahead and cut the image myself.
    – Justin
    May 22, 2012 at 16:42
  • In the future you can do a custom template for that field. Using PHP you can write a conditional that displays if the field is blank and call the image style that you're using for resizing May 22, 2012 at 16:57
  • 2
    @Justin: this is NOT A SOLUTION! You should mark Marijke Luttekes's answer as accepted, because her answer REALLY solves the problem! Please look at my comment, I just tried it, and her solution worked perfectly. Thanks for changing the accepted answer to hers! :)
    – Sk8erPeter
    Sep 9, 2012 at 18:54
30

I have just found the answer to this question via Drupal.org. You have to use a URI like this:

public://user_pictures/default.png

in your account settings.

Here, public:// stands for your public files location (often sites/default/files/). What comes after that, is the location of your image within public files. If you do this, the default image is treated like normal user images.

4
  • 3
    +1, wow, you were absolutely right! On the admin/config/people/accounts site, I firstly set the default picture to sites/default/files/user-pictures/person.png; the result: no default images displayed in my view where I list users; after changing the path to public://user-pictures/person.png, the default picture appeared! I didn't think this is so simple. Thank you! :)
    – Sk8erPeter
    Sep 9, 2012 at 18:53
  • 1
    This is the correct answer. Adds the default user image with the correct image style without having to modify the view. Great answer. Apr 11, 2013 at 16:20
  • really helpful and drupal way :) Aug 6, 2013 at 11:50
  • The answer is correct, and I suggest to follow the relative bug report: drupal.org/node/1413824
    – FiNeX
    Aug 18, 2013 at 11:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.