forked from CGM_Public/pretix_original
Fix crash trying to thumbnail invalid image
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
# <https://www.gnu.org/licenses/>.
|
# <https://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import logging
|
||||||
# This file is based on an earlier version of pretix which was released under the Apache License 2.0. The full text of
|
# This file is based on an earlier version of pretix which was released under the Apache License 2.0. The full text of
|
||||||
# the Apache License 2.0 can be obtained at <http://www.apache.org/licenses/LICENSE-2.0>.
|
# the Apache License 2.0 can be obtained at <http://www.apache.org/licenses/LICENSE-2.0>.
|
||||||
#
|
#
|
||||||
@@ -73,6 +74,8 @@ from pretix.helpers.thumb import get_thumbnail
|
|||||||
from ..settings import settings_hierarkey
|
from ..settings import settings_hierarkey
|
||||||
from .organizer import Organizer, Team
|
from .organizer import Organizer, Team
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class EventMixin:
|
class EventMixin:
|
||||||
def clean(self):
|
def clean(self):
|
||||||
@@ -534,9 +537,17 @@ class Event(EventMixin, LoggedModel):
|
|||||||
logo_file = self.settings.get('logo_image', as_type=str, default='')[7:]
|
logo_file = self.settings.get('logo_image', as_type=str, default='')[7:]
|
||||||
og_file = self.settings.get('og_image', as_type=str, default='')[7:]
|
og_file = self.settings.get('og_image', as_type=str, default='')[7:]
|
||||||
if og_file:
|
if og_file:
|
||||||
img = get_thumbnail(og_file, '1200').thumb.url
|
try:
|
||||||
|
img = get_thumbnail(og_file, '1200').thumb.url
|
||||||
|
except:
|
||||||
|
logger.exception(f'Failed to create thumbnail of {og_file}')
|
||||||
|
img = default_storage.url(og_file)
|
||||||
elif logo_file:
|
elif logo_file:
|
||||||
img = get_thumbnail(logo_file, '5000x120').thumb.url
|
try:
|
||||||
|
img = get_thumbnail(logo_file, '5000x1200').thumb.url
|
||||||
|
except:
|
||||||
|
logger.exception(f'Failed to create thumbnail of {logo_file}')
|
||||||
|
img = default_storage.url(logo_file)
|
||||||
if img:
|
if img:
|
||||||
return urljoin(build_absolute_uri(self, 'presale:event.index'), img)
|
return urljoin(build_absolute_uri(self, 'presale:event.index'), img)
|
||||||
|
|
||||||
|
|||||||
@@ -38,5 +38,5 @@ def thumb(source, arg):
|
|||||||
try:
|
try:
|
||||||
return get_thumbnail(source, arg).thumb.url
|
return get_thumbnail(source, arg).thumb.url
|
||||||
except:
|
except:
|
||||||
logger.exception('Failed to create thumbnail')
|
logger.exception(f'Failed to create thumbnail of {source}')
|
||||||
return default_storage.url(source)
|
return default_storage.url(source)
|
||||||
|
|||||||
@@ -208,7 +208,12 @@ def price_dict(item, price):
|
|||||||
|
|
||||||
|
|
||||||
def get_picture(event, picture):
|
def get_picture(event, picture):
|
||||||
return urljoin(build_absolute_uri(event, 'presale:event.index'), get_thumbnail(picture.name, '60x60^').thumb.url)
|
try:
|
||||||
|
thumb = get_thumbnail(picture.name, '60x60^').thumb.url
|
||||||
|
except:
|
||||||
|
logger.exception(f'Failed to create thumbnail of {picture.name}')
|
||||||
|
thumb = default_storage.url(picture.name)
|
||||||
|
return urljoin(build_absolute_uri(event, 'presale:event.index'), thumb)
|
||||||
|
|
||||||
|
|
||||||
class WidgetAPIProductList(EventListMixin, View):
|
class WidgetAPIProductList(EventListMixin, View):
|
||||||
|
|||||||
Reference in New Issue
Block a user