code: @Override
    public RenditionMetadata getRendition(MediaArgs mediaArgs) {
  
      // get list of file extensions requested
      String[] requestedFileExtensions = getRequestedFileExtensions(mediaArgs);
  
      // if the array is null file extensions constraints are applied, but do not match to each other
      // - no rendition can fulfill these constraints
      if (requestedFileExtensions == null) {
        return null;
      }
  
      // check if a specific media size is requested
      boolean isSizeMatchingRequest = isSizeMatchingRequest(mediaArgs, requestedFileExtensions);
  
      // get rendition candidates matching for file extensions
      Set<RenditionMetadata> candidates = getRendtionsMatchingFileExtensions(requestedFileExtensions, mediaArgs);
  
      // if request does not contain any size restrictions return original image or first by filename matching rendition
      if (!isSizeMatchingRequest) {
        return getOriginalOrFirstRendition(candidates);
      }
  
      // original rendition is a image - check for matching rendition or build virtual one
      RenditionMetadata exactMatchRendition = getExactMatchRendition(candidates, mediaArgs);
      if (exactMatchRendition != null) {
        return exactMatchRendition;
      }
  
      // get rendition virtual rendition downscaled from existing one
      RenditionMetadata virtualRendition = getVirtualRendition(candidates, mediaArgs);
      if (virtualRendition != null) {
        return virtualRendition;
      }
  
      // no match found
      return null;
    }
docs: Get rendition (probably virtual) for given media arguments.
  @param mediaArgs Media arguments
  @return Rendition or null if none is matching