Fix broken package icons
This commit is contained in:
parent
ef9860b6cc
commit
f1edfcebc0
|
@ -444,6 +444,9 @@ class Package(db.Model):
|
||||||
"downloads": self.downloads
|
"downloads": self.downloads
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def getThumbnailOrPlaceholder(self, level=2):
|
||||||
|
return self.getThumbnailURL(level) or "/static/placeholder.png"
|
||||||
|
|
||||||
def getThumbnailURL(self, level=2):
|
def getThumbnailURL(self, level=2):
|
||||||
screenshot = self.screenshots.filter_by(approved=True).order_by(db.asc(PackageScreenshot.id)).first()
|
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
|
return screenshot.getThumbnailURL(level) if screenshot is not None else None
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
<img
|
<img
|
||||||
class="img-fluid"
|
class="img-fluid"
|
||||||
style="max-height: 22px; max-width: 22px;"
|
style="max-height: 22px; max-width: 22px;"
|
||||||
src="{{ entry.package.getThumbnailURL(1) }}" />
|
src="{{ entry.package.getThumbnailOrPlaceholder() }}" />
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% macro render_pkgtile(package, show_author) -%}
|
{% macro render_pkgtile(package, show_author) -%}
|
||||||
<li class="packagetile flex-fill"><a href="{{ package.getDetailsURL() }}"
|
<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="packagegridscrub"></div>
|
||||||
<div class="packagegridinfo">
|
<div class="packagegridinfo">
|
||||||
<h3>
|
<h3>
|
||||||
|
|
|
@ -186,7 +186,7 @@
|
||||||
<img
|
<img
|
||||||
class="img-fluid"
|
class="img-fluid"
|
||||||
style="max-height: 22px; max-width: 22px;"
|
style="max-height: 22px; max-width: 22px;"
|
||||||
src="{{ t.package.getThumbnailURL(1) }}" /><br />
|
src="{{ t.package.getThumbnailOrPlaceholder() }}" /><br />
|
||||||
|
|
||||||
<span class="pl-2">
|
<span class="pl-2">
|
||||||
{{ t.package.title }}
|
{{ t.package.title }}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<img
|
<img
|
||||||
class="img-fluid"
|
class="img-fluid"
|
||||||
style="max-height: 22px; max-width: 22px;"
|
style="max-height: 22px; max-width: 22px;"
|
||||||
src="{{ package.getThumbnailURL(1) }}" />
|
src="{{ package.getThumbnailOrPlaceholder() }}" />
|
||||||
|
|
||||||
<span class="pl-2">
|
<span class="pl-2">
|
||||||
{{ package.title }}
|
{{ package.title }}
|
||||||
|
|
|
@ -37,7 +37,7 @@ Notifications
|
||||||
<img
|
<img
|
||||||
class="img-fluid"
|
class="img-fluid"
|
||||||
style="max-height: 22px; max-width: 22px;"
|
style="max-height: 22px; max-width: 22px;"
|
||||||
src="{{ n.package.getThumbnailURL(1) }}" />
|
src="{{ n.package.getThumbnailOrPlaceholder() }}" />
|
||||||
|
|
||||||
<span class="pl-2">
|
<span class="pl-2">
|
||||||
{{ n.package.title }}
|
{{ n.package.title }}
|
||||||
|
@ -75,7 +75,7 @@ Notifications
|
||||||
<img
|
<img
|
||||||
class="img-fluid"
|
class="img-fluid"
|
||||||
style="max-height: 22px; max-width: 22px;"
|
style="max-height: 22px; max-width: 22px;"
|
||||||
src="{{ n.package.getThumbnailURL(1) }}" />
|
src="{{ n.package.getThumbnailOrPlaceholder() }}" />
|
||||||
|
|
||||||
<span class="pl-2">
|
<span class="pl-2">
|
||||||
{{ n.package.title }}
|
{{ n.package.title }}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<ul class="card-body d-flex p-0 flex-row flex-wrap justify-content-start align-content-start p-4">
|
<ul class="card-body d-flex p-0 flex-row flex-wrap justify-content-start align-content-start p-4">
|
||||||
{% for s in screenshots %}
|
{% for s in screenshots %}
|
||||||
<li class="packagetile flex-fill"><a href="{{ s.getEditURL() }}"
|
<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="packagegridscrub"></div>
|
||||||
<div class="packagegridinfo">
|
<div class="packagegridinfo">
|
||||||
<h3>
|
<h3>
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<img
|
<img
|
||||||
class="img-fluid"
|
class="img-fluid"
|
||||||
style="max-height: 22px; max-width: 22px;"
|
style="max-height: 22px; max-width: 22px;"
|
||||||
src="{{ package.getThumbnailURL(1) }}" />
|
src="{{ package.getThumbnailOrPlaceholder() }}" />
|
||||||
|
|
||||||
<span class="pl-2">
|
<span class="pl-2">
|
||||||
{{ package.title }}
|
{{ package.title }}
|
||||||
|
|
Loading…
Reference in New Issue