Skip to content

Add Image constructor for typical use-cases #21967

@knoobie

Description

@knoobie

Describe your motivation

Add a shortcut Image constructor to ease usage.

  public Image(byte[] imageContent, String imageName) {
    this.setSrc(DownloadHandler.fromInputStream(event -> {
      return new DownloadResponse(new ByteArrayInputStream(imageContent), imageName,
        URLConnection.guessContentTypeFromName(imageContent), imageContent.length
      );
    }).inline());
    this.setAlt(imageName);
  }

Additional context

https://vaadin.com/forum/t/streamresource-used-to-set-image-src/178326/2

Metadata

Metadata

Assignees

Projects

Status

Maybe

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions