class mdfy.elements.image.MdImage(src: str, alt: str = '')[source]

Bases: MdElement

Represents a Markdown image.

src

The source URL or path of the image.

Type:

str

alt

The alternative text for the image.

Type:

str

Examples

>>> from mdfy.elements import MdImage
>>>
>>> image = MdImage("https://example.com/image.png")
>>> print(image)
![](https://example.com/image.png)
>>>
>>> image = MdImage("https://example.com/image.png", alt="Example image")
>>> print(image)
![Example image](https://example.com/image.png)
__str__() str[source]

Returns a string representation of the image in Markdown format.

Returns:

String representation of the image.

Return type:

str

Warning

If the image source is None, it will log a warning and set the source to an empty string.