简体   繁体   中英

AEM adaptive image working on Author but not on Publish

I've followed these instructions to get a custom adaptive image component working on my AEM author install. Problem is, it doesn't fetch a lower resolution image on publish like it does on author. Could this have something to do with the fact that the servlet reference is in the apps directory and is therefore not accessible on a publish server?

Name your config file com.day.cq.wcm.foundation.impl.AdaptiveImageComponentServlet.xml and place it in config folder in your app. The trick here is to have the sling.servlet.resourceTypes property. This property should include the path to your custom adaptive image component (highlighted in yellow in below sample – for a custom comp in path /apps/APPNAME/components/content/adaptiveimage).

<?xml version="1.0" encoding="UTF-8"?>

<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"

    jcr:primaryType="sling:OsgiConfig"

    adapt.supported.widths="[320,480,476,620]"

    sling.servlet.resourceTypes="[foundation/components/adaptiveimage,APPNAME/components/content/adaptiveimage]"/>

I used CRX/DE lite for this, so it worked a little differently. It involved creating a "sling:OsgiConfig" node named "com.day.cq.wcm.foundation.impl.AdaptiveImageComponentServlet.xml" under apps/myproject/config.

I added a String named "adapt.supported.widths" with the "Multi" button clicked and added the values 320, 480, 476, and 620.

I added another Multi String named "sling.servlet.resourceTypes" and added the values "foundation/components/adaptiveimage" and "myproject/components/content/adaptiveimage"

After that, I could see the image resolution changing for my custom component when I resized the browser window.

As I've stated above, I'm noticing that in Publish the adaptive image that I implemented successfully in Author using this method does not work. The image will resize in publish but will only request the "high" image resolution. I've checked to see if it is just calling it "high" when in fact the actual resolution is low. When I look closely at the image when I resize it to the same level on author and publish you can see a difference between author which shows a much lower res image and publish which shows a much higher res image.

Could this have something to do with the fact that we've created a node with the type "sling:OsgiConfig" named "com.day.cq.wcm.foundation.impl.AdaptiveImageComponentServlet.xml" under apps/myproject/config?

Perhaps publish doesn't have access to this node as it's in the apps directory? Have I missed something else here?

This is not an access issue as the OSGI configurations gets bound to service internally and are independent of logged in user. Can you verify that the configurations are getting bound correctly on your publish instance -

  • Goto /system/console/configMgr on your publish instance
  • Search for Adaptive Image Component Servlet and click on it.
  • Check if property Configuration Binding is empty stating Unbound or new configuration
  • If so, click on Save and your configurations will be effective. Post this test again on your publish instance

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM