Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Link Image to Post?

Is there an easy mod to link the user photo to the post that it's displaying next to rather than the profile page?

Comments

  • peregrineperegrine MVP
    edited May 2013

    You really need to photoshop and upload some sample images of what you want.

    A picture is worth a thousand words and you only have 22 words which don't specify much.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • hgtonighthgtonight ∞ · New Moderator
    edited May 2013

    Open up /plugins/IndexPhotos/class.indexphotos.plugin.php and replace the DisplayPhoto method with the one below:

    protected function DisplayPhoto($Sender) {
      // Build user object & output photo
      $FirstUser = UserBuilder($Sender->EventArguments['Discussion'], 'First');
      $Photo = ChangeBasename($FirstUser->Photo, 'n%s');
      echo Anchor(Img(Gdn_Upload::Url($Photo), array('class' => 'ProfilePhotoMedium')), $Sender->EventArguments['DiscussionUrl']);
    }
    

    Tested in 2.0.18.8 on Firefox.

    NOTE - This is changing the expected behavior on the discussions list. The consistent expected behavior in Vanilla when clicking on an avatar, is being linked to that profile. I would caution against using it.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • @hgtonight said:
    Open up /plugins/IndexPhotos/class.indexphotos.plugin.php and replace the DisplayPhoto method with the one below:

    protected function DisplayPhoto($Sender) {
      // Build user object & output photo
      $FirstUser = UserBuilder($Sender->EventArguments['Discussion'], 'First');
      $Photo = ChangeBasename($FirstUser->Photo, 'n%s');
      echo Anchor(Img(Gdn_Upload::Url($Photo), array('class' => 'ProfilePhotoMedium')), $Sender->EventArguments['DiscussionUrl']);
    }
    

    Tested in 2.0.18.8 on Firefox.

    NOTE - This is changing the expected behavior on the discussions list. The consistent expected behavior in Vanilla when clicking on an avatar, is being linked to that profile. I would caution against using it.

    Thanks, I understand that this is bit of expected behavior but I'm worried my users will think that they are going to the post from that page. I will consider, thanks.

  • Something seems to be off with the code, all of my image urls had an 'n' in them so I removed the 'n' from 'n%s' line 4 and it seemed to work.

    Thanks

  • peregrineperegrine MVP
    edited May 2013

    the n distinguishes between the thumbnail or the full pic in

    userpics/

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.