protected @Nullable HtmlElement<?> getPictureElement(@NotNull Media media) {
    PictureSource[] pictureSources = media.getMediaRequest().getMediaArgs().getPictureSources();

    Picture picture = new Picture();

    // add source elements (only if matching renditions found)
    boolean foundAnySource = false;
    for (PictureSource pictureSource : pictureSources) {
      Source source = new Source();
      if (pictureSource.getMedia() != null) {
        source.setMedia(pictureSource.getMedia());
      }
      String srcSet = getSrcSetRenditions(media, pictureSource.getMediaFormat(), pictureSource.getWidths());
      if (srcSet != null) {
        source.setSrcSet(srcSet);
        picture.add(source);
        foundAnySource = true;
      }
    }

    // add image element
    HtmlElement<?> image = getImageElement(media);
    if (image == null) {
      return null;
    }

    if (foundAnySource) {
      picture.add(image);
      return picture;
    }
    else {
      return image;
    }
  }
protected @ Nullable HtmlElement < ? > getPictureElement ( @ NotNull Media media ) { PictureSource [ ] pictureSources = media . getMediaRequest ( ) . getMediaArgs ( ) . getPictureSources ( ) ; Picture picture = new Picture ( ) ; boolean foundAnySource = false ; for ( PictureSource pictureSource : pictureSources ) { Source source = new Source ( ) ; if ( pictureSource . getMedia ( ) != null ) { source . setMedia ( pictureSource . getMedia ( ) ) ; } String srcSet = getSrcSetRenditions ( media , pictureSource . getMediaFormat ( ) , pictureSource . getWidths ( ) ) ; if ( srcSet != null ) { source . setSrcSet ( srcSet ) ; picture . add ( source ) ; foundAnySource = true ; } } HtmlElement < ? > image = getImageElement ( media ) ; if ( image == null ) { return null ; } if ( foundAnySource ) { picture . add ( image ) ; return picture ; } else { return image ; } }
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