Open skilljobs opened 1 year ago
I am having the same issue.
Modified the content before returning the response in the view using util function:
from bs4 import BeautifulSoup
def normalize_html_image_urls(request, content):
site_url = request.build_absolute_uri('/')
# Use BeautifulSoup to parse the HTML
soup = BeautifulSoup(content, 'html.parser')
# Find all <img> tags and update their src attribute
for img in soup.find_all('img'):
if img.has_attr('src'):
src = img['src']
if not src.startswith('http'):
img['src'] = site_url[:-1] + src
# Convert the updated HTML back to a string
updated_content = str(soup)
return updated_content
Well it takes time to do so but I have changed their source code. https://github.com/summernote/django-summernote/blob/main/django_summernote/views.py You can override class SummernoteUploadAttachment(UserPassesTestMixin, View):
Can you give example usage?
Suppose images are uploaded from admin.example.com and it stores like "/media/django-summernote/2023-1-11/adsdfsfdf.png" Not the full URL. So in API, the url is not containing main site. How to fix it?