congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
MediaHandler
Code IndexAdd Tabnine to your IDE (free)

How to use
MediaHandler
in
io.wcm.handler.media

Best Java code snippets using io.wcm.handler.media.MediaHandler (Showing top 5 results out of 315)

origin: io.wcm/io.wcm.handler.richtext

/**
 * Extracts media metadata from the DOM element attributes and resolves them to a {@link Media} object.
 * @param element DOM element
 * @return Media metadata
 */
private Media getImageMedia(Element element) {
 String ref = element.getAttributeValue("src");
 if (StringUtils.isNotEmpty(ref)) {
  ref = unexternalizeImageRef(ref);
 }
 return mediaHandler.get(ref).build();
}
origin: io.wcm/io.wcm.dam.asset-service

public Media resolve(MediaHandler mediaHandler) {
 return mediaHandler.get(assetPath)
   .mediaFormatName(mediaFormatName)
   .fixedDimension(width, height)
   .build();
}
origin: io.wcm/io.wcm.handler.media

@PostConstruct
private void activate() {
 MediaBuilder builder = mediaHandler.get(resource);
 if (StringUtils.isNotEmpty(mediaFormat)) {
  builder.mediaFormatName(mediaFormat);
 }
 if (StringUtils.isNotEmpty(refProperty)) {
  builder.refProperty(refProperty);
 }
 if (StringUtils.isNotEmpty(cropProperty)) {
  builder.cropProperty(cropProperty);
 }
 if (StringUtils.isNotEmpty(rotationProperty)) {
  builder.rotationProperty(rotationProperty);
 }
 if (StringUtils.isNotEmpty(cssClass)) {
  builder.property(PROP_CSS_CLASS, cssClass);
 }
 media = builder.build();
}
origin: io.wcm.samples/io.wcm.samples.app

@PostConstruct
private void activate() {
 media = mediaHandler.get(resource, new MediaArgs(mediaFormat)).build();
 if (media.isValid() && media.getElement() != null) {
  HtmlElement element = media.getElement();
  if (StringUtils.isNotEmpty(cssClass)) {
   element.addCssClass(cssClass);
  }
  ValueMap props = resource.getValueMap();
  int imageWidth = props.get("imageWidth", 0);
  if (imageWidth > 0) {
   element.setAttribute("width", Integer.toString(imageWidth));
  }
  int imageHeight = props.get("imageWidth", 0);
  if (imageHeight > 0) {
   element.setAttribute("height", Integer.toString(imageHeight));
  }
 }
}
origin: io.wcm/io.wcm.handler.link

@SuppressWarnings("null")
@Override
public @NotNull Link resolveLink(@NotNull Link link) {
 LinkRequest linkRequest = link.getLinkRequest();
 ValueMap props = linkRequest.getResourceProperties();
 // get properties
 String mediaRef = props.get(LinkNameConstants.PN_LINK_MEDIA_REF, String.class);
 boolean isDownload = props.get(LinkNameConstants.PN_LINK_MEDIA_DOWNLOAD, false);
 MediaArgs mediaArgs = new MediaArgs()
   // only allow linking to "download" media formats
   .download(true)
   .contentDispositionAttachment(isDownload)
   .urlMode(linkRequest.getLinkArgs().getUrlMode());
 // resolve media library reference
 Media media = mediaHandler.get(mediaRef, mediaArgs).build();
 if (media != null) {
  // set resovled media references information in link metadata
  link.setUrl(media.getUrl());
  link.setTargetAsset(media.getAsset());
  link.setTargetRendition(media.getRendition());
 }
 // mark link as invalid if a reference was set that could not be resolved
 if (link.getUrl() == null && StringUtils.isNotEmpty(mediaRef)) {
  link.setLinkReferenceInvalid(true);
 }
 return link;
}
io.wcm.handler.mediaMediaHandler

Javadoc

Manages media resolving and markup generation.

The interface is implemented by a Sling Model. You can adapt from org.apache.sling.api.SlingHttpServletRequest or org.apache.sling.api.resource.Resource to get a context-specific handler instance.

Most used methods

  • get
    Build media which is referenced in the resource (as property or inline binary data).

Popular in Java

  • Parsing JSON documents to java classes using gson
  • putExtra (Intent)
  • getContentResolver (Context)
  • setRequestProperty (URLConnection)
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now