No announcement yet.
  • Filter
  • Time
Clear All
new posts

    TileGrid DetailViewerField Image Aspect Ratio

    We have a TileGrid showing images in each tile with a DetailViewerField, with the type "image". All of the images are all different sizes. Most of them are more or less square so they look great. There are a couple that are very wide and the thumbnail gets clipped instead of the image scaled down to fit the tile.

    Is there a way to control this behavior so that the image thumbnail is contained within the tile instead of being clipped?

    Here's how we have the field defined:

            final DetailViewerField imageField = new DetailViewerField(DSConst.DocumentSQL.DOCUMENT);
            imageField.setDetailFormatter((o, r, detailViewerField) -> {
                final String url = StringUtils.isNotEmpty(r.getAttribute(DSConst.DocumentDataSQL.URL)) ? r.getAttribute(DSConst.DocumentDataSQL.URL)
                        : "data:" + r.getAttribute(DSConst.DocumentSQL.MIME_TYPE) + ";base64," + o;
                detailViewerField.setImageSize((Integer) null);
                return url;
    Without the line setting the imageSize to null everything gets very distorted.
    Last edited by aderosso; 23 Jan 2023, 14:06.

    Yes - each tile is effectively a DetailViewer and TileGrid.fields gives you the ability to specify the fields for that DetailViewer. So you can control the fields they, and DetailViewerField gives you the ability to control whether images are shown at natural size or scaled.


      Where do I set natural size or scaled?


        Isomorphic any update here? Is there a natural size or scaled option to select? Or do I need to do something like this: