Commit 2c9aa484 authored by Marco Cavalli's avatar Marco Cavalli
Browse files

feat: apply width and height when provided

parent c3a058de
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -177,6 +177,8 @@ def change_images_to_use_high_quality(soup: BeautifulSoup, src: str):
    """
    for img in soup.find_all("img"):
        img_src = img.get("src")
        width = img.get("width")
        height = img.get("height")
        img_name, _ = os.path.splitext(img_src)
        img_name = img_name.split("/")[-1]
        img_size = None  # Initialize the image size
@@ -206,7 +208,16 @@ def change_images_to_use_high_quality(soup: BeautifulSoup, src: str):
        #     img_src = img_src.replace(".png", ".jpg")

        img["src"] = img_src
        if img_size:
        if width and not height:
            img["width"] = width
            img["height"] = None
        elif height and not width:
            img["height"] = height
            img["width"] = None
        elif width and height:
            img["width"] = width
            img["height"] = height
        elif img_size:
            if img_size[0] is not None:
                img["width"] = img_size[0]
            if img_size[1] is not None: