L'image a une url absolue
This commit is contained in:
parent
1256adcb8a
commit
bf773686f9
@ -923,9 +923,12 @@ class Event(models.Model):
|
|||||||
else:
|
else:
|
||||||
return recurrences[0]
|
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"):
|
if self.local_image and hasattr(self.local_image, "url"):
|
||||||
try:
|
try:
|
||||||
|
if request:
|
||||||
|
return request.build_absolute_uri(self.local_image.url)
|
||||||
|
else:
|
||||||
return self.local_image.url
|
return self.local_image.url
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
|
|
||||||
{% block title %}{% block og_title %}{{ event.title }}{% endblock %}{% endblock %}
|
{% 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 og_description %}{% if event.description %}{{ event.description |truncatewords:20|linebreaks }}{% else %}{{ block.super }}{% endif %}{% endblock %}
|
||||||
|
|
||||||
{% block entete_header %}
|
{% block entete_header %}
|
||||||
|
@ -180,3 +180,7 @@ def tw_badge(event):
|
|||||||
return mark_safe('<span class="badge tw-badge">TW</span>')
|
return mark_safe('<span class="badge tw-badge">TW</span>')
|
||||||
else:
|
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