Fix broken package icons

This commit is contained in:
rubenwardy 2021-01-29 20:21:17 +00:00
parent ef9860b6cc
commit f1edfcebc0
8 changed files with 11 additions and 8 deletions

View File

@ -444,6 +444,9 @@ class Package(db.Model):
"downloads": self.downloads
}
def getThumbnailOrPlaceholder(self, level=2):
return self.getThumbnailURL(level) or "/static/placeholder.png"
def getThumbnailURL(self, level=2):
screenshot = self.screenshots.filter_by(approved=True).order_by(db.asc(PackageScreenshot.id)).first()
return screenshot.getThumbnailURL(level) if screenshot is not None else None

View File

@ -50,7 +50,7 @@
<img
class="img-fluid"
style="max-height: 22px; max-width: 22px;"
src="{{ entry.package.getThumbnailURL(1) }}" />
src="{{ entry.package.getThumbnailOrPlaceholder() }}" />
</div>
{% endif %}

View File

@ -1,6 +1,6 @@
{% macro render_pkgtile(package, show_author) -%}
<li class="packagetile flex-fill"><a href="{{ package.getDetailsURL() }}"
style="background-image: url({{ package.getThumbnailURL() or '/static/placeholder.png' }});">
style="background-image: url({{ package.getThumbnailOrPlaceholder(2) }});">
<div class="packagegridscrub"></div>
<div class="packagegridinfo">
<h3>

View File

@ -186,7 +186,7 @@
<img
class="img-fluid"
style="max-height: 22px; max-width: 22px;"
src="{{ t.package.getThumbnailURL(1) }}" /><br />
src="{{ t.package.getThumbnailOrPlaceholder() }}" /><br />
<span class="pl-2">
{{ t.package.title }}

View File

@ -8,7 +8,7 @@
<img
class="img-fluid"
style="max-height: 22px; max-width: 22px;"
src="{{ package.getThumbnailURL(1) }}" />
src="{{ package.getThumbnailOrPlaceholder() }}" />
<span class="pl-2">
{{ package.title }}

View File

@ -37,7 +37,7 @@ Notifications
<img
class="img-fluid"
style="max-height: 22px; max-width: 22px;"
src="{{ n.package.getThumbnailURL(1) }}" />
src="{{ n.package.getThumbnailOrPlaceholder() }}" />
<span class="pl-2">
{{ n.package.title }}
@ -75,7 +75,7 @@ Notifications
<img
class="img-fluid"
style="max-height: 22px; max-width: 22px;"
src="{{ n.package.getThumbnailURL(1) }}" />
src="{{ n.package.getThumbnailOrPlaceholder() }}" />
<span class="pl-2">
{{ n.package.title }}

View File

@ -18,7 +18,7 @@
<ul class="card-body d-flex p-0 flex-row flex-wrap justify-content-start align-content-start p-4">
{% for s in screenshots %}
<li class="packagetile flex-fill"><a href="{{ s.getEditURL() }}"
style="background-image: url({{ s.getThumbnailURL(3) or '/static/placeholder.png' }});">
style="background-image: url({{ s.getThumbnailOrPlaceholder(3) }});">
<div class="packagegridscrub"></div>
<div class="packagegridinfo">
<h3>

View File

@ -15,7 +15,7 @@
<img
class="img-fluid"
style="max-height: 22px; max-width: 22px;"
src="{{ package.getThumbnailURL(1) }}" />
src="{{ package.getThumbnailOrPlaceholder() }}" />
<span class="pl-2">
{{ package.title }}