Skip to content

Commit

Permalink
Fix avatar url when site.baseurl exists (cotes2020#253)
Browse files Browse the repository at this point in the history
(cherry picked from commit 30c2a3d)
  • Loading branch information
cotes2020 authored and linkliu committed Jan 18, 2021
1 parent 5b8e987 commit 26b6979
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions _includes/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@

<div class="profile-wrapper text-center">
<div id="avatar">
<a href="{{ site.baseurl }}/" alt="avatar" class="mx-auto">
{% assign avatar_url = site.avatar %}

{% unless avatar_url contains '://' %}
{% if site.img_cdn %}
{% assign avatar_url = avatar_url | prepend: site.img_cdn %}
{% else %}
{% assign avatar_url = avatar_url | relative_url %}
{% endif %}
{% endunless %}

<a href="{{ '/' | relative_url }}" alt="avatar" class="mx-auto">
{% capture avatar_url %}
{%- if site.avatar contains '://' -%}
{{ site.avatar }}
{%- elsif site.img_cdn != '' and site.img_cdn -%}
{{ site.avatar | prepend: site.img_cdn }}
{%- else -%}
{{ site.avatar | relative_url }}
{%- endif -%}
{% endcapture %}
<img src="{{ avatar_url }}" alt="avatar" onerror="this.style.display='none'">
</a>
</div>
Expand Down

0 comments on commit 26b6979

Please sign in to comment.