mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 19:41:11 +00:00
OpenGraph: fall back on book cover when preview images are disabled
This commit is contained in:
parent
ea9d3f8ba1
commit
646b27b7a7
2 changed files with 4 additions and 3 deletions
|
@ -195,7 +195,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
||||||
"""image to use as preview in meta tags when only this status is shown"""
|
"""image to use as preview in meta tags when only this status is shown"""
|
||||||
if self.mention_books.exists():
|
if self.mention_books.exists():
|
||||||
book = self.mention_books.first()
|
book = self.mention_books.first()
|
||||||
return book.preview_image
|
return book.preview_image or book.cover
|
||||||
else:
|
else:
|
||||||
return self.user.preview_image
|
return self.user.preview_image
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ class BookStatus(Status):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def page_image(self):
|
def page_image(self):
|
||||||
return self.book.preview_image or super().page_image
|
return self.book.preview_image or self.book.cover or super().page_image
|
||||||
|
|
||||||
|
|
||||||
class Comment(BookStatus):
|
class Comment(BookStatus):
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
{% block title %}{{ book|book_title }}{% endblock %}
|
{% block title %}{{ book|book_title }}{% endblock %}
|
||||||
|
|
||||||
{% block opengraph %}
|
{% block opengraph %}
|
||||||
{% include 'snippets/opengraph.html' with title=book.title description=book|book_description image=book.preview_image %}
|
{% firstof book.preview_image book.cover as book_image %}
|
||||||
|
{% include 'snippets/opengraph.html' with title=book.title description=book|book_description image=book_image %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
Loading…
Reference in a new issue