So, I'm trying to get Author Pane working with my Advanced Forum, as well as ImageCache_profiles in order to have well configured user avatar image sizes across my site.

However, I'm running into a problem where Author Pane/Adv Forum requires the full path for default image as opposed to Nodes/Comments which only need the file name (if file placed in sites/default/files)

For example:

In user/account settings, if I set the default image path to something like:

Default picture: sites/default/files/pictures/default.jpg

It works just fine for regular nodes and comments. The user avatar displays where it should at the top of the post. However, it causes the avatar display for Advanced Forum + Author Pane to fail, showing an image not found.

But, if I then change the user/account settings default image path to something that just shows the file name (but the image file is still stored in same place):

Default picture: default.jpg

It then works properly for Advanced Forum + Author Pane, but now fails for regulars nodes and comments.

I can't win?

Is there a way to change the type of path that Author Pane is expecting? I looked at author-pane-user-picture.tpl.php and I don't see anything that stands out.

Comments

Michelle’s picture

Author Pane hands off the image to Imagecache... It doesn't really do anything much with it aside from that. I haven't looked at it in D7 but it (Imagecache, that is) was pretty picky about what it got back in D6. My guess is the issue is there but I'm going to leave this active as I can't say for sure without testing.

Michelle

davidcsonka’s picture

I think you're probably right. I duplicated my issue request over at ImageCache_profiles. It would seem to me that the path behavior for Adv Forum/Author Panes is proper.

I'm not sure why the full path needs to be added for the other instances like Node/Comments (through ImageCache), since the File-Paths configuration should provide the necessary path automatically.

Michelle’s picture

Status: Active » Postponed (maintainer needs more info)

Ok, let us know what you find out, please. :)

Michelle

davidcsonka’s picture

Michelle, based on my own investigation, there does appear to be an issue with Author Pane and ImageCache_profiles both being active, even if it is not Author Pane's fault.

In the following situation, I believe this is specifically related to the issues surrounding default user pictures, as handled by ImageCache_profiles:

In my Advanced Forum, on topics where the author is a user which does not have a defined user picture (and thus uses the default user picture provided by admin) I get the following error:

Notice: Trying to get property of non-object in include() (line 25 of C:\xampp\htdocs\sites\all\modules\author_pane\author-pane-user-picture.tpl.php).

When I comment out the code here:
<?php print file_create_url($account->picture->uri); ?>

... the error stops.

I believe this is because Author Pane cannot locate a proper URI attributed to the default user picture, possibly related to how ImageCache_profiles is messing with this.

Scyther’s picture

The error you have found is known. See #1217780: Notice: Trying to get property of non-object ...

As you say, if the user has no picture, the picture object in the $account variable dont exists. This is overall and has nothing to do with imagecache_profiles.

davidcsonka’s picture

Noted, thank you.

Scyther’s picture

It seems that the best way to fill in the Default picture field is to use a uri schema for the public files directory public:// or private://.

Ex: public://pictures/default.jpg instead of sites/default/files/pictures/default.jpg

davidcsonka’s picture

Oh wow, I think that completely solved *all* of my problems related to the user pictures. Thanks!!

Michelle’s picture

@Scyther: Is there anything we can change in AP for that? I remember issues with the default picture in D6 and I was stuck because Imagecache required a certain format and so that's what I had to give it.

Michelle

Scyther’s picture

Because the Default picture field has no "standar way" to fill it, it can be so many possible ways so it is hard to support everyone. But I have checked out how the template_preprocess_user_picture
does and it could be good to in a way like that.

In short, we require that the default picture has public:// or private:// (or any other stream wrapper, file_valid_uri($filepath)) to be styled with any image style. If it is "sites/default/files/..." and it may work if we send it in for image style, AP will ignoring it. External images (http://) can not be style anyway.

What do you think about that Michelle?

Michelle’s picture

I'm not quite sure I'm following... Are you saying that AP should ignore something that will work with imagecache? If so, why?

Scyther’s picture

Right now if you put 'sites/default/files/default.jpg' as default picture, it will not be showing up correctly in AP. Image style gives this url back 'http://example.com/sites/default/files/styles/thumbnail/public/sites/def...'.

If you has 'default.jpg' as default pictures it will work in AP, but it then fails for Drupals core user picture function. "Drupal core" give back 'http://example.com/default.jpg'. So this is pure luck for it to work with AP.

If it is 'http://example.com/sites/default/files/default.jpg' AP returns 'http://styles/thumbnail/http/example.com/sites/default/files/default.jpg' because of bad checking of the default picture.

So my suggestion is that, if the default picture has public:// or private:// or any other streamwrapper, it should be styled with that image style that has been selected. If it don't have it, it should only be displayed as the original image. Like in template_preprocess_user_picture().

// has public:// or any other valid uri that is checked in file_valid_uri().
      if (module_exists('image') && file_valid_uri($filepath) && $style = variable_get('user_picture_style', '')) {
        $variables['user_picture'] = theme('image_style', array('style_name' => $style, 'path' => $filepath, 'alt' => $alt, 'title' => $alt));
      }
// is "sites/default/files/default-picture.jpg" or a external image
      else {
        $variables['user_picture'] = theme('image', array('path' => $filepath, 'alt' => $alt, 'title' => $alt));
      }
Michelle’s picture

Ah, gotcha. Sounds fine to me. :)

Michelle

Scyther’s picture

Status: Postponed (maintainer needs more info) » Fixed

Changes for 'template_preprocess_author_pane_user_picture' function commited.

http://drupalcode.org/project/author_pane.git/commit/a4e03be

Michelle’s picture

Thanks!

Status: Fixed » Closed (fixed)

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