Use a team's custom image for social media previews of their events

This commit is contained in:
Michael Hall 2018-09-04 22:45:49 -04:00
parent 3d057c7f6e
commit 67626a59d9
2 changed files with 9 additions and 5 deletions

View file

@ -383,6 +383,14 @@ class Team(models.Model):
else:
return static('img/team_placeholder.png')
@property
def full_img_url(self):
if self.card_img_url.startswith('http'):
return self.card_img_url
else:
site = Site.objects.get(id=1)
return "https://%s%s" % (site.domain, self.card_img_url)
@property
def location_name(self):
if self.city:

View file

@ -8,11 +8,7 @@
<meta property="og:type" content="website" />
<meta property="og:title" content="{{event.name}}" />
<meta property="og:description" content="{{event.summary}}" />
{% if event.team.category %}
<meta property="og:image" content="{{event.team.category.img_url}}" />
{% else %}
<meta property="og:image" content="https://gettogether.community{% static 'img/team_placeholder.png' %}" />
{% endif %}
<meta property="og:image" content="{{event.team.full_img_url}}" />
{% endblock %}
{% block styles %}