code: protected void applyWcmMarkup(@Nullable HtmlElement<?> mediaElement, @NotNull Media media) {
      // further processing in edit or preview mode
      Resource resource = media.getMediaRequest().getResource();
      if (mediaElement != null && resource != null && wcmMode != null) {
  
        switch (wcmMode) {
          case EDIT:
            // enable drag&drop from content finder
            media.getMediaSource().enableMediaDrop(mediaElement, media.getMediaRequest());
            // set custom IPE crop ratios
            media.getMediaSource().setCustomIPECropRatios(mediaElement, media.getMediaRequest());
            break;
  
          case PREVIEW:
            // enable drag&drop from content finder
            media.getMediaSource().enableMediaDrop(mediaElement, media.getMediaRequest());
            // add diff decoration
            if (request != null) {
              String refProperty = StringUtils.defaultString(media.getMediaRequest().getRefProperty(),
                  mediaHandlerConfig.getMediaRefProperty());
              MediaMarkupBuilderUtil.addDiffDecoration(mediaElement, resource, refProperty, request, mediaHandlerConfig);
            }
            // set custom IPE crop ratios
            media.getMediaSource().setCustomIPECropRatios(mediaElement, media.getMediaRequest());
            break;
  
          default:
            // do nothing
        }
  
      }
    }
docs: Apply Markup for Drag&amp;Drop mode and Diff decoration in WCM edit/preview mode.
  @param mediaElement Media element
  @param media Media