Browse Source

fix(watermark): remove watermark from narrators, authors, article and collection thumbnails

master
Mohsen Taba 4 days ago
parent
commit
306537b6f1
  1. 12
      apps/article/serializers_admin.py
  2. 12
      apps/hadis/serializers/serializers_admin.py

12
apps/article/serializers_admin.py

@ -12,18 +12,14 @@ class AbsoluteImageField(serializers.ImageField):
if not uploaded: if not uploaded:
return uploaded return uploaded
from utils.watermark import apply_watermark_to_upload
watermarked = apply_watermark_to_upload(uploaded, position="bottom_left")
target_file = watermarked or uploaded
compressed_bytes = maybe_compress_uploaded_file(target_file)
compressed_bytes = maybe_compress_uploaded_file(uploaded)
if compressed_bytes is None: if compressed_bytes is None:
return target_file
return uploaded
return SimpleUploadedFile( return SimpleUploadedFile(
name=getattr(target_file, "name", "image"),
name=getattr(uploaded, "name", "image"),
content=compressed_bytes, content=compressed_bytes,
content_type=getattr(target_file, "content_type", None),
content_type=getattr(uploaded, "content_type", None),
) )
def to_representation(self, value): def to_representation(self, value):

12
apps/hadis/serializers/serializers_admin.py

@ -39,18 +39,14 @@ class AbsoluteImageField(serializers.ImageField):
if not uploaded: if not uploaded:
return uploaded return uploaded
from utils.watermark import apply_watermark_to_upload
watermarked = apply_watermark_to_upload(uploaded, position="bottom_left")
target_file = watermarked or uploaded
compressed_bytes = maybe_compress_uploaded_file(target_file)
compressed_bytes = maybe_compress_uploaded_file(uploaded)
if compressed_bytes is None: if compressed_bytes is None:
return target_file
return uploaded
return SimpleUploadedFile( return SimpleUploadedFile(
name=getattr(target_file, "name", "image"),
name=getattr(uploaded, "name", "image"),
content=compressed_bytes, content=compressed_bytes,
content_type=getattr(target_file, "content_type", None),
content_type=getattr(uploaded, "content_type", None),
) )
def to_representation(self, value): def to_representation(self, value):

Loading…
Cancel
Save