private void setMimeType(CMVisual mediaItem, MediaContent mediaContent) { try { String type = mediaItem.getData().getContentType().toString(); MimeType mimeType = new MimeType(type); mediaContent.setMedium(mimeType.getPrimaryType()); mediaContent.setType(mimeType.toString()); } catch (MimeTypeParseException e) { LOG.error("Cannot create mimetype for " + mediaItem, e); } }
private String getTumbnailUrl( HttpServletRequest request, HttpServletResponse response, CMVisual mediaItem) { CMPicture picture = mediaItem.getPicture(); if (picture != null) { Blob blob = picture.getTransformedData(IMAGE_RATIO); if (blob != null) { return createUrlForTransformedBlob( blob, request, response, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT); } } return null; }