fix(blog_post): Ensure images are public if shown on website
This commit is contained in:
parent
92ee2ce291
commit
6a6ccc034c
2 changed files with 10 additions and 2 deletions
|
|
@ -216,9 +216,11 @@ def get_file_name(fname: str, optional_suffix: str | None = None) -> str:
|
|||
return f"{partial}{suffix}{extn}"
|
||||
|
||||
|
||||
def extract_images_from_doc(doc: "Document", fieldname: str):
|
||||
def extract_images_from_doc(doc: "Document", fieldname: str, is_private=True):
|
||||
content = doc.get(fieldname)
|
||||
content = extract_images_from_html(doc, content, is_private=(not doc.meta.make_attachments_public))
|
||||
if doc.meta.make_attachments_public:
|
||||
is_private = False
|
||||
content = extract_images_from_html(doc, content, is_private=is_private)
|
||||
if frappe.flags.has_dataurl:
|
||||
doc.set(fieldname, content)
|
||||
|
||||
|
|
|
|||
|
|
@ -95,6 +95,12 @@ class BlogPost(WebsiteGenerator):
|
|||
|
||||
self.set_read_time()
|
||||
|
||||
if self.is_website_published():
|
||||
from frappe.core.doctype.file.utils import extract_images_from_doc
|
||||
|
||||
# Extract images first before the standard image extraction to ensure they are public.
|
||||
extract_images_from_doc(self, "content", is_private=False)
|
||||
|
||||
def reset_featured_for_other_blogs(self):
|
||||
all_posts = frappe.get_all("Blog Post", {"featured": 1})
|
||||
for post in all_posts:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue