[main] Content..
Some checks failed
Build, Push, and Deploy to Nomad / docker-nomad (push) Has been cancelled

This commit is contained in:
2025-01-07 22:42:46 +01:00
parent 8573e330d6
commit 2b9361c7e9
17 changed files with 49 additions and 5 deletions

View File

@@ -9,10 +9,9 @@ from PIL import Image
class FileHandler:
def __init__(self, category=None, image_type=None, filename=None):
def __init__(self, category=None, image_type=None, filename=None) -> Path:
self.filename = filename
self.category = category
self.image_type = image_type
@property
@@ -50,7 +49,8 @@ class FileHandler:
f" image_type='{self.image_type}',\n"
f" src_file='{self.src_file}',\n"
f" dest_file='{self.dest_file}',\n"
f" dest_filename='{self.dest_filename}'\n"
f" dest_filename='{self.dest_filename}',\n"
f" dest_path='{self.dest_path}'\n"
f")"
)
@@ -165,8 +165,9 @@ class ImageService:
width = width or default_size.get( "width" )
height = height or default_size.get( "height" )
file_path = FileHandler(category = category,image_type = image_type,filename = filename)
p = Path(file_path.dest_path)
p.mkdir(parents = True, exist_ok = True)
self.validate_image( file_path, width = width,height=height, overwrite = True )
tag = f'<img src="/{file_path.dest_filename_webp}" alt="{alt}"'
# if width:
# tag += f' width="{width}"'
@@ -174,7 +175,6 @@ class ImageService:
# tag += f' height="{height}"'
if css_class:
tag += f' class="{css_class}"'
tag += ">"
return tag