add support for article specific og image
This commit is contained in:
parent
1d190fe182
commit
6b689704b0
5 changed files with 49 additions and 6 deletions
|
@ -51,6 +51,15 @@ class Article(ImageReference):
|
|||
help_text="Link this article to a cloud provider",
|
||||
)
|
||||
|
||||
# Open Graph image for social sharing
|
||||
og_image = models.ImageField(
|
||||
upload_to="article_og_images/",
|
||||
blank=True,
|
||||
null=True,
|
||||
validators=[validate_image_size],
|
||||
help_text="Optional Open Graph image for social sharing (max 1MB). If not provided, the article's main image will be used."
|
||||
)
|
||||
|
||||
# Publishing controls
|
||||
is_published = models.BooleanField(
|
||||
default=False, help_text="Only published articles are visible to users"
|
||||
|
@ -90,6 +99,15 @@ class Article(ImageReference):
|
|||
return self.image_library.image
|
||||
return None
|
||||
|
||||
@property
|
||||
def get_og_image(self):
|
||||
"""Returns the Open Graph image for social sharing"""
|
||||
# Use specific OG image if available
|
||||
if self.og_image:
|
||||
return self.og_image
|
||||
# Fall back to main article image
|
||||
return self.get_image
|
||||
|
||||
@property
|
||||
def related_to(self):
|
||||
"""Returns a string describing what this article is related to"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue