HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Display UserPhoto without logged

Hello everybody,

As I change this code to display the profile picture without the need to log in ? (translated by google 1)
how to change this code to show the profile picture , without being logged in ? (translated by google 2)

<?php $Session = Gdn::Session(); if ($Session->IsValid()) { echo Img(Gdn_Upload::Url(ChangeBasename($Session->User->Photo, 'p%s')), array('width' => '37px', 'height' => '37px')); }?>

Thanks and sorry for my bad english =)

Comments

  • R_JR_J Ex-Fanboy Munich Admin
    edited December 2015

    @RafaelScotti said:
    Hello everybody,

    As I change this code to display the profile picture without the need to log in ? (translated by google 1)
    how to change this code to show the profile picture , without being logged in ? (translated by google 2)

    <?php $Session = Gdn::Session(); if ($Session->IsValid()) { echo Img(Gdn_Upload::Url(ChangeBasename($Session->User->Photo, 'p%s')), array('width' => '37px', 'height' => '37px')); }?>

    Thanks and sorry for my bad english =)

    <?php
    $Session = Gdn::Session();
    // if ($Session->IsValid()) {
        echo Img(Gdn_Upload::Url(ChangeBasename($Session->User->Photo, 'p%s')), array('width' => '37px', 'height' => '37px'));
    // }
    ?>
    
  • R_JR_J Ex-Fanboy Munich Admin

    The problem is, that there will be no picture available for a guest. It displays the picture of the currently logged in user.
    So basically, you would have to implement a fallback

    <?php
    $Session = Gdn::Session();
    if ($Session->IsValid()) {
        echo Img(Gdn_Upload::Url(ChangeBasename($Session->User->Photo, 'p%s')), array('width' => '37px', 'height' => '37px'));
    } else {
            echo Img('uploads/some_fallback_picture_you_have_to_upload.png', array('width' => '37px', 'height' => '37px'));
    }
    ?>
    
  • Thanks brother

Sign In or Register to comment.