Skip to content

Commit

Permalink
Fix svg icons display issue in plugin list and plugin detail (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xpirix authored Jan 31, 2024
1 parent 339dcd3 commit 5054f5d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
13 changes: 10 additions & 3 deletions qgis-app/plugins/templates/plugins/plugin_detail.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends 'plugins/plugin_base.html' %}{% load i18n static thumbnail %}
{% load local_timezone %}
{% load plugin_utils %}
{% block extrajs %}
{{ block.super }}
<script type="text/javascript" src="{% static "js/jquery.cookie.js" %}"></script>
Expand Down Expand Up @@ -144,9 +145,15 @@ <h2>
{% endif %}
<h2>{{ object.name }}
{% if object.icon and object.icon.file %}
{% thumbnail object.icon "128x128" upscale=False format="PNG" as im %}
<img class="pull-right plugin-icon" alt="{% trans "Plugin icon" %}" src="{{ im.url }}" width="{{ im.x }}" height="{{ im.y }}" />
{% endthumbnail %}
{% with image_extension=object.icon.name|file_extension %}
{% if image_extension == 'svg' %}
<img class="pull-right plugin-icon" alt="{% trans "Plugin icon" %}" src="{{ object.icon.url }}" width="24" height="24" />
{% else %}
{% thumbnail object.icon "128x128" upscale=False format="PNG" as im %}
<img class="pull-right plugin-icon" alt="{% trans "Plugin icon" %}" src="{{ im.url }}" width="{{ im.x }}" height="{{ im.y }}" />
{% endthumbnail %}
{% endif %}
{% endwith %}
{% endif %}
</h2>
<div>
Expand Down
13 changes: 10 additions & 3 deletions qgis-app/plugins/templates/plugins/plugin_list.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends 'plugins/plugin_base.html' %}{% load i18n bootstrap_pagination humanize static sort_anchor range_filter thumbnail %}
{% load local_timezone %}
{% load plugin_utils %}
{% block extrajs %}
<script type="text/javascript" src="{% static "js/jquery.cookie.js" %}"></script>
<script language="javascript">
Expand Down Expand Up @@ -80,9 +81,15 @@ <h2>{% if title %}{{title}}{% else %}{% trans "All plugins" %}{% endif %}</h2>
<tr class="pmain {% if object.deprecated %} error deprecated{% endif %}" id="pmain{{object.pk}}">
<td><a title="{% if object.deprecated %} [DEPRECATED] {% endif %}{% trans "Click here for plugin details" %}" href="{% url "plugin_detail" object.package_name %}">
{% if object.icon and object.icon.file %}
{% thumbnail object.icon "24x24" format="PNG" as im %}
<img class="plugin-icon" alt="{% trans "Plugin icon" %}" src="{{ im.url }}" width="{{ im.x }}" height="{{ im.y }}" />
{% endthumbnail %}
{% with image_extension=object.icon.name|file_extension %}
{% if image_extension == 'svg' %}
<img class="pull-right plugin-icon" alt="{% trans "Plugin icon" %}" src="{{ object.icon.url }}" width="24" height="24" />
{% else %}
{% thumbnail object.icon "24x24" format="PNG" as im %}
<img class="plugin-icon" alt="{% trans "Plugin icon" %}" src="{{ im.url }}" width="{{ im.x }}" height="{{ im.y }}" />
{% endthumbnail %}
{% endif %}
{% endwith %}
{% else %}
<img height="32" width="32" class="plugin-icon" src="{% static "images/qgis-icon-32x32.png" %}" alt="{% trans "Plugin icon" %}" />
{% endif %}
Expand Down
4 changes: 4 additions & 0 deletions qgis-app/plugins/templatetags/plugin_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ def plugin_title(context):
if "page_title" in context:
title = context["page_title"]
return title

@register.filter
def file_extension(value):
return value.split('.')[-1].lower()

0 comments on commit 5054f5d

Please sign in to comment.