diff --git a/apps/news/management/commands/news_optimize_images.py b/apps/news/management/commands/news_optimize_images.py index 63906037..440afbc2 100644 --- a/apps/news/management/commands/news_optimize_images.py +++ b/apps/news/management/commands/news_optimize_images.py @@ -1,7 +1,6 @@ # coding=utf-8 from django.core.management.base import BaseCommand -from project.settings import SCHEMA_URI, SITE_DOMAIN_URI from utils.methods import get_url_images_in_text, get_image_meta_by_url from news.models import News from sorl.thumbnail import get_thumbnail @@ -30,11 +29,6 @@ class Command(BaseCommand): def optimize(self, text, max_size, max_quality): """optimize news images""" for image in get_url_images_in_text(text): - if not image.startswith('http'): - image = f'{SCHEMA_URI}://{SITE_DOMAIN_URI}{image}' - - self.stdout.write(self.style.SUCCESS(f'{image} {text}')) - try: size, width, height = get_image_meta_by_url(image) except IOError as ie: diff --git a/apps/utils/methods.py b/apps/utils/methods.py index b9855545..a8f5171e 100644 --- a/apps/utils/methods.py +++ b/apps/utils/methods.py @@ -207,7 +207,7 @@ def section_name_into_index_name(section_name: str): def get_url_images_in_text(text): """Find images urls in text""" - return re.findall(r'[^\"\'=\s]+\.jpe?g|png|gif|svg', text) + return re.findall(r'\', text) def get_image_meta_by_url(url) -> (int, int, int):