Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix svg icons display issue in plugin list and plugin detail #348

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -96,9 +97,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()
Loading