def make_replaced_box(element, box, image):
    """Wrap an image in a replaced box.

    That box is either block-level or inline-level, depending on what the
    element should be.

    """
    type_ = (
        boxes.BlockReplacedBox if 'block' in box.style['display']
        else boxes.InlineReplacedBox)
    new_box = type_(element.tag, box.style, element, image)
    # TODO: check other attributes that need to be copied
    # TODO: find another solution
    new_box.string_set = box.string_set
    new_box.bookmark_label = box.bookmark_label
    return new_box
Wrap an image in a replaced box.

That box is either block-level or inline-level, depending on what the
element should be.
weasyprint/html.py