diff --git a/app/models/packages.py b/app/models/packages.py index 2421f5a..c6e4072 100644 --- a/app/models/packages.py +++ b/app/models/packages.py @@ -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 diff --git a/app/templates/macros/audit_log.html b/app/templates/macros/audit_log.html index 6e89575..7700816 100644 --- a/app/templates/macros/audit_log.html +++ b/app/templates/macros/audit_log.html @@ -50,7 +50,7 @@ + src="{{ entry.package.getThumbnailOrPlaceholder() }}" /> {% endif %} diff --git a/app/templates/macros/packagegridtile.html b/app/templates/macros/packagegridtile.html index 3f9d364..725f8cc 100644 --- a/app/templates/macros/packagegridtile.html +++ b/app/templates/macros/packagegridtile.html @@ -1,6 +1,6 @@ {% macro render_pkgtile(package, show_author) -%}
  • + style="background-image: url({{ package.getThumbnailOrPlaceholder(2) }});">

    diff --git a/app/templates/macros/threads.html b/app/templates/macros/threads.html index 70d63cf..08e0971 100644 --- a/app/templates/macros/threads.html +++ b/app/templates/macros/threads.html @@ -186,7 +186,7 @@
    + src="{{ t.package.getThumbnailOrPlaceholder() }}" />
    {{ t.package.title }} diff --git a/app/templates/macros/todo.html b/app/templates/macros/todo.html index 8e432bd..02676d9 100644 --- a/app/templates/macros/todo.html +++ b/app/templates/macros/todo.html @@ -8,7 +8,7 @@ + src="{{ package.getThumbnailOrPlaceholder() }}" /> {{ package.title }} diff --git a/app/templates/notifications/list.html b/app/templates/notifications/list.html index d2f5490..38c3b9b 100644 --- a/app/templates/notifications/list.html +++ b/app/templates/notifications/list.html @@ -37,7 +37,7 @@ Notifications + src="{{ n.package.getThumbnailOrPlaceholder() }}" /> {{ n.package.title }} @@ -75,7 +75,7 @@ Notifications + src="{{ n.package.getThumbnailOrPlaceholder() }}" /> {{ n.package.title }} diff --git a/app/templates/todo/editor.html b/app/templates/todo/editor.html index 1887280..5924c5e 100644 --- a/app/templates/todo/editor.html +++ b/app/templates/todo/editor.html @@ -18,7 +18,7 @@