code: protected @Nullable HtmlElement<?> getImageElement(@NotNull Media media) {
      Image img = null;
  
      MediaArgs mediaArgs = media.getMediaRequest().getMediaArgs();
      Asset asset = media.getAsset();
      Rendition rendition = media.getRendition();
  
      String url = null;
      if (rendition != null) {
        url = rendition.getUrl();
      }
  
      if (url != null) {
        img = new Image(url);
  
        // Alternative text
        String altText = null;
        if (asset != null) {
          altText = asset.getAltText();
        }
        if (StringUtils.isNotEmpty(altText)) {
          img.setAlt(altText);
        }
  
        // set width/height
        if (rendition != null && mediaArgs.getImageSizes() == null && mediaArgs.getPictureSources() == null) {
          long height = rendition.getHeight();
          if (height > 0) {
            img.setHeight(height);
          }
          long width = rendition.getWidth();
          if (width > 0) {
            img.setWidth(width);
          }
        }
  
        // set image sizes/srcset
        ImageSizes imageSizes = mediaArgs.getImageSizes();
        if (imageSizes != null) {
          MediaFormat primaryMediaFormat = getFirstMediaFormatWithRatio(media);
          if (primaryMediaFormat != null) {
            String srcSet = getSrcSetRenditions(media, primaryMediaFormat, imageSizes.getWidths());
            if (srcSet != null) {
              img.setSrcSet(srcSet);
              img.setSizes(imageSizes.getSizes());
            }
          }
        }
  
      }
  
      // set additional attributes
      setAdditionalAttributes(img, media);
  
      return img;
    }
docs: Create an <code>img</code> element that displays the given rendition image.
  @param media Media metadata
  @return <code>img</code> element with properties or null if media metadata is invalid