L'image a une url absolue
This commit is contained in:
parent
1256adcb8a
commit
bf773686f9
@ -923,10 +923,13 @@ class Event(models.Model):
|
||||
else:
|
||||
return recurrences[0]
|
||||
|
||||
def get_image_url(self):
|
||||
def get_image_url(self, request=None):
|
||||
if self.local_image and hasattr(self.local_image, "url"):
|
||||
try:
|
||||
return self.local_image.url
|
||||
if request:
|
||||
return request.build_absolute_uri(self.local_image.url)
|
||||
else:
|
||||
return self.local_image.url
|
||||
except:
|
||||
pass
|
||||
if self.image:
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
{% block title %}{% block og_title %}{{ event.title }}{% endblock %}{% endblock %}
|
||||
{% block og_image %}{% if event.has_image_url %}{{ event.get_image_url }}{% else %}{{ block.super }}{% endif %}{% endblock %}
|
||||
{% block og_image %}{% if event.has_image_url %}{{ event|get_image_uri:request }}{% else %}{{ block.super }}{% endif %}{% endblock %}
|
||||
{% block og_description %}{% if event.description %}{{ event.description |truncatewords:20|linebreaks }}{% else %}{{ block.super }}{% endif %}{% endblock %}
|
||||
|
||||
{% block entete_header %}
|
||||
|
@ -179,4 +179,8 @@ def tw_badge(event):
|
||||
if event.tags and len([t for t in event.tags if t.startswith("TW:")]) > 0:
|
||||
return mark_safe('<span class="badge tw-badge">TW</span>')
|
||||
else:
|
||||
return ""
|
||||
return ""
|
||||
|
||||
@register.filter
|
||||
def get_image_uri(event, request):
|
||||
return event.get_image_url(request)
|
Loading…
Reference in New Issue
Block a user