toHtml method

  1. @override
String toHtml()
override

Converts this image into an HTML representation.

  • Wraps the <img> tag with a <figure> if a caption is provided.
  • Wraps it with an <a> tag if linkUrl is set.
  • Otherwise, wraps it in a <div> container to apply styles.

Implementation

@override
String toHtml() {
  final imageHtml = _buildImageHtml();

  if (linkUrl != null) {
    return _buildImageWithLink(imageHtml);
  }

  if (caption != null) {
    return _buildImageWithCaption(imageHtml);
  }

  return _wrapWithContainer(imageHtml);
}