mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-09 14:37:36 +01:00
Use level 4 thumbnail for cover image
This commit is contained in:
parent
5a506ef557
commit
294037ec70
@ -603,20 +603,18 @@ class Package(db.Model):
|
|||||||
def getThumbnailOrPlaceholder(self, level=2):
|
def getThumbnailOrPlaceholder(self, level=2):
|
||||||
return self.getThumbnailURL(level) or "/static/placeholder.png"
|
return self.getThumbnailURL(level) or "/static/placeholder.png"
|
||||||
|
|
||||||
def getThumbnailURL(self, level=2):
|
def getThumbnailURL(self, level=2, abs=False):
|
||||||
screenshot = self.main_screenshot
|
screenshot = self.main_screenshot
|
||||||
return screenshot.getThumbnailURL(level) if screenshot is not None else None
|
url = screenshot.getThumbnailURL(level) if screenshot is not None else None
|
||||||
|
if abs:
|
||||||
def getMainScreenshotURL(self, absolute=False):
|
|
||||||
screenshot = self.main_screenshot
|
|
||||||
if screenshot is None:
|
|
||||||
return None
|
|
||||||
|
|
||||||
if absolute:
|
|
||||||
from app.utils import abs_url
|
from app.utils import abs_url
|
||||||
return abs_url(screenshot.url)
|
return abs_url(url)
|
||||||
else:
|
else:
|
||||||
return screenshot.url
|
return url
|
||||||
|
|
||||||
|
def getCoverImageURL(self):
|
||||||
|
screenshot = self.cover_image or self.main_screenshot
|
||||||
|
return screenshot and screenshot.getThumbnailURL(4)
|
||||||
|
|
||||||
def getURL(self, endpoint, absolute=False, **kwargs):
|
def getURL(self, endpoint, absolute=False, **kwargs):
|
||||||
if absolute:
|
if absolute:
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
</ol>
|
</ol>
|
||||||
<div class="carousel-inner">
|
<div class="carousel-inner">
|
||||||
{% for package in featured %}
|
{% for package in featured %}
|
||||||
{% set cover_image = package.cover_image.url or package.getMainScreenshotURL() %}
|
{% set cover_image = package.getCoverImageURL() %}
|
||||||
{% set tags = package.tags | sort(attribute="views", reverse=True) %}
|
{% set tags = package.tags | sort(attribute="views", reverse=True) %}
|
||||||
<div class="carousel-item {% if loop.index == 1 %}active{% endif %}">
|
<div class="carousel-item {% if loop.index == 1 %}active{% endif %}">
|
||||||
<a href="{{ package.getURL("packages.view") }}">
|
<a href="{{ package.getURL("packages.view") }}">
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
<meta name="og:description" content="{{ _('Mods for %(title)s', title=package.title) }}"/>
|
<meta name="og:description" content="{{ _('Mods for %(title)s', title=package.title) }}"/>
|
||||||
<meta name="description" content="{{ _('Mods for %(title)s', title=package.title) }}"/>
|
<meta name="description" content="{{ _('Mods for %(title)s', title=package.title) }}"/>
|
||||||
<meta name="og:url" content="{{ package.getURL('packages.game_hub', absolute=True) }}"/>
|
<meta name="og:url" content="{{ package.getURL('packages.game_hub', absolute=True) }}"/>
|
||||||
{% if package.getMainScreenshotURL() %}
|
{% if package.getThumbnailURL(3, True) %}
|
||||||
<meta name="og:image" content="{{ package.getMainScreenshotURL(absolute=True) }}"/>
|
<meta name="og:image" content="{{ package.getThumbnailURL(3, True) }}"/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
<meta name="og:description" content="{{ package.short_desc }}"/>
|
<meta name="og:description" content="{{ package.short_desc }}"/>
|
||||||
<meta name="description" content="{{ package.short_desc }}"/>
|
<meta name="description" content="{{ package.short_desc }}"/>
|
||||||
<meta name="og:url" content="{{ package.getURL("packages.view", absolute=True) }}"/>
|
<meta name="og:url" content="{{ package.getURL("packages.view", absolute=True) }}"/>
|
||||||
{% if package.getMainScreenshotURL() %}
|
{% if package.getThumbnailURL(3, True) %}
|
||||||
<meta name="og:image" content="{{ package.getMainScreenshotURL(absolute=True) }}"/>
|
<meta name="og:image" content="{{ package.getThumbnailURL(3, True) }}"/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@
|
|||||||
{% set package_warning=_("Non-free media") %}
|
{% set package_warning=_("Non-free media") %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<main>
|
<main>
|
||||||
{% set cover_image = package.cover_image.url or package.getMainScreenshotURL() %}
|
{% set cover_image = package.getCoverImageURL() %}
|
||||||
<header class="jumbotron pb-3"
|
<header class="jumbotron pb-3"
|
||||||
style="background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.7)), url('{{ cover_image }}');
|
style="background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.7)), url('{{ cover_image }}');
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
|
Loading…
Reference in New Issue
Block a user