Hello, I want to habilitate the option Web-Optimized Image Delivery on my custom component, the idea is that the user can upload an asset on the authoring configuration of the component (cq:dialog) and then convert the file on Webp Format, I was following the documentation of:
https://experienceleague.adobe.com/docs/experience-manager-core-components/using/developing/web-opti...
And
But it doesn't work, I don't know if I need to make a step with other settings or if I made wrong a step, this is my Java Model of the component that I want to implement Web-Optimized Image Delivery, the property that have the asset is "fileReference":
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
HI @Aaron_Dempwolff,
You need to implement AssetDelivery.getDeliveryURL in your Sling Model. Check ExampleWebOptimizedImagesImpl from here: Web-optimized image delivery Java™ APIs.
The AssetDelivery OSGi Service is only satisfied when running in AEM as a Cloud Service. On AEM SDK, references to the AssetDelivery OSGi service return null.
Here is the Sample Code:
public class MosaicModel {
@Reference(cardinality = ReferenceCardinality.OPTIONAL)
private volatile AssetDelivery assetDelivery;
@Self
@Required
private SlingHttpServletRequest request;
private String getWebOptimizedUrl(
ResourceResolver resourceResolver,
String path, Map<String, Object> options) {
Resource resource = resourceResolver.getResource(path);
Asset asset = DamUtil.resolveToAsset(resource);
// These 3 options are required for the AssetDelivery API to work
// Else it will return null
options.put("path", asset.getPath());
options.put("format", options.get("format"));
options.put("seoname", options.get("seoname"));
return assetDelivery.getDeliveryURL(resource, options);
}
public String getFileReference() {
// Set the AssetDelivery options to request a web-optimized rendition.
// These options can be set as required by the implementation
// (Dialog, pass in from HTL via @RequestAttribute)
final Map<String, Object> options = new HashMap<>();
options.put("format", "webp");
options.put("preferwebp", "true");
options.put("width", "350");
options.put("height", "350");
return getWebOptimizedUrl(
request.getResourceResolver(), fileReference, options);
}
}
Views
Replies
Total Likes
HI @Aaron_Dempwolff,
You need to implement AssetDelivery.getDeliveryURL in your Sling Model. Check ExampleWebOptimizedImagesImpl from here: Web-optimized image delivery Java™ APIs.
The AssetDelivery OSGi Service is only satisfied when running in AEM as a Cloud Service. On AEM SDK, references to the AssetDelivery OSGi service return null.
Here is the Sample Code:
public class MosaicModel {
@Reference(cardinality = ReferenceCardinality.OPTIONAL)
private volatile AssetDelivery assetDelivery;
@Self
@Required
private SlingHttpServletRequest request;
private String getWebOptimizedUrl(
ResourceResolver resourceResolver,
String path, Map<String, Object> options) {
Resource resource = resourceResolver.getResource(path);
Asset asset = DamUtil.resolveToAsset(resource);
// These 3 options are required for the AssetDelivery API to work
// Else it will return null
options.put("path", asset.getPath());
options.put("format", options.get("format"));
options.put("seoname", options.get("seoname"));
return assetDelivery.getDeliveryURL(resource, options);
}
public String getFileReference() {
// Set the AssetDelivery options to request a web-optimized rendition.
// These options can be set as required by the implementation
// (Dialog, pass in from HTL via @RequestAttribute)
final Map<String, Object> options = new HashMap<>();
options.put("format", "webp");
options.put("preferwebp", "true");
options.put("width", "350");
options.put("height", "350");
return getWebOptimizedUrl(
request.getResourceResolver(), fileReference, options);
}
}
Views
Replies
Total Likes
Thank you very much, I will try to integrate the API to my Java class, I have only one question, one of the errors I had is with the library:
com.adobe.cq.wcm.spi.AssetDelivery
I couldn't find it, all the other libraries if it finds them but this one in specific not, I am using the version of AEM 6.5.
What can cause that it doesn't find the library, does it have to do with that I have to modify the path of the library in another way or do I have to install something else?
Views
Replies
Total Likes
Import is functioning correctly when using Uber-Jar version 6.5.15. However, when employing Uber-Jar version 6.5.0, there is an issue with the "cannot be resolved" error. You may want to consider resolving this by updating your Uber-Jar version.
While the AssetDelivery import works in AEM 6.5.15, it's important to note that this functionality is available exclusively for AEM as a Cloud Service (AEMaaCS).
Views
Replies
Total Likes
Is there any tutorial or documentation of how to update uber-jar?
Views
Replies
Total Likes
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<version>6.5.15</version>
<!--<classifier>apis</classifier>-->
<scope>provided</scope>
</dependency>
UberJar and the other related artifacts are available on Maven Central Repository instead of Adobe Public Maven repository (repo.adobe.com). The main UberJar file is renamed to uber-jar-<version>.jar. So, there is no classifier, with apis as the value, for the dependency tag.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies