Picture linked to user's profile in user-picture.tpl.php D7: In my user-picture.tpl.php template I have the following code:

&lt;div class="user-image"&gt;
  &lt;?php
    $user = user_load($account-&gt;uid);
    print theme('image_style', array('style_name' =&gt; 'square', 'path' =&gt; $user-&gt;picture-&gt;uri));
  ?&gt;
&lt;/div&gt;


This short snippet sets the default, site wide, for the user picture.

When using views, linking the picture is easy. But when not using views, how can I change this so that the picture is linked to the user's profile?

Any help on this would be greatly appreciated. :)
template_preprocess_user_picture() uses the following code.

  $variables ['user_picture'] = '';
  if (variable_get('user_pictures', 0)) {
    $account = $variables['account'];
    if (!empty($account-&gt;picture)) {
      if (is_numeric($account-&gt;picture)) {
        $account-&gt;picture = file_load($account-&gt;picture);
      }
      if (!empty($account-&gt;picture-&gt;uri)) {
        $filepath = $account-&gt;picture-&gt;uri;
      }
    }
    elseif (variable_get('user_picture_default', '')) {
      $filepath = variable_get('user_picture_default', '');
    }
    if (isset($filepath)) {
      $alt = t("@user's picture", array('@user' =&gt; format_username($account)));
      if (module_exists('image') &amp;&amp; file_valid_uri($filepath) &amp;&amp; $style = variable_get('user_picture_style', '')) {
        $variables['user_picture'] = theme('image_style', array('style_name' =&gt; $style, 'path' =&gt; $filepath, 'alt' =&gt; $alt, 'title' =&gt; $alt));
      }
      else {
        $variables['user_picture'] = theme('image', array('path' =&gt; $filepath, 'alt' =&gt; $alt, 'title' =&gt; $alt));
      }
      if (!empty($account-&gt;uid) &amp;&amp; user_access('access user profiles')) {
        $attributes = array('attributes' =&gt; array('title' =&gt; t('View user profile.')), 'html' =&gt; TRUE);
        $variables['user_picture'] = l($variables ['user_picture'], "user/$account-&gt;uid", $attributes);
      }
    }
  }


Assuming you just want to use a specific image style for the image, and hard code it in your theme, I would use the following code for mytheme_preprocess_user_picture(). (Replace mytheme with the short name of the theme.)

  $variables ['user_picture'] = '';
  if (variable_get('user_pictures', 0)) {
    $account = $variables['account'];
    if (!empty($account-&gt;picture)) {
      if (is_numeric($account-&gt;picture)) {
        $account-&gt;picture = file_load($account-&gt;picture);
      }
      if (!empty($account-&gt;picture-&gt;uri)) {
        $filepath = $account-&gt;picture-&gt;uri;
      }
    }
    elseif (variable_get('user_picture_default', '')) {
      $filepath = variable_get('user_picture_default', '');
    }
    if (isset($filepath)) {
      $alt = t("@user's picture", array('@user' =&gt; format_username($account)));
      if (module_exists('image') &amp;&amp; file_valid_uri($filepath)) {
        $variables['user_picture'] = theme('image_style', array('style_name' =&gt; 'square', 'path' =&gt; $filepath, 'alt' =&gt; $alt, 'title' =&gt; $alt));
      }
      else {
        $variables['user_picture'] = theme('image', array('path' =&gt; $filepath, 'alt' =&gt; $alt, 'title' =&gt; $alt));
      }
      if (!empty($account-&gt;uid) &amp;&amp; user_access('access user profiles')) {
        $attributes = array('attributes' =&gt; array('title' =&gt; t('View user profile.')), 'html' =&gt; TRUE);
        $variables['user_picture'] = l($variables ['user_picture'], "user/$account-&gt;uid", $attributes);
      }
    }
  }


Doing so, the template file would just need to print $user_picture.

Keep in mind that the image style used for the user image is contained in a Drupal variable. I would investigate on how to change that variable for the theme you are using, even though you would then need to change it back for the other themes, in the case your theme is not anymore the active one.