code: public static @NotNull Dimension getMediaformatDimension(@NotNull Media media) {
      // Create dummy image element to be displayed in Edit mode as placeholder.
      MediaArgs mediaArgs = media.getMediaRequest().getMediaArgs();
      MediaFormat[] mediaFormats = mediaArgs.getMediaFormats();
  
      // detect width/height - either from media args, or from first media format
      long width = mediaArgs.getFixedWidth();
      long height = mediaArgs.getFixedHeight();
      if ((width == 0 || height == 0) && mediaFormats != null && mediaFormats.length > 0) {
        MediaFormat firstMediaFormat = mediaArgs.getMediaFormats()[0];
        Dimension dimension = firstMediaFormat.getMinDimension();
        if (dimension != null) {
          width = dimension.getWidth();
          height = dimension.getHeight();
        }
      }
  
      // fallback to min width/height
      if (width == 0) {
        width = MediaMarkupBuilder.DUMMY_MIN_DIMENSION;
      }
      if (height == 0) {
        height = MediaMarkupBuilder.DUMMY_MIN_DIMENSION;
      }
  
      return new Dimension(width, height);
    }
docs: Get dimension from first media format defined in media args. Fall back to dummy min. dimension if none specified.
  @param media Media metadata
  @return Dimension