Highlighted

Issue with teaser images with resource mapping

rajeevy89244319

27-02-2019

Hi All,

I am using resource mapping to shorten the website URL. It works fine for all the scenarios except that core images authored as part of teaser component are not showing up. When I tried to debug the issue, I found out that the issue is happening as image path is pointing to nodes under /content and because of resource mapping image path is also getting shortened and thus returning 404.

When I try to access image with full path then it loads up properly.

E.g.

I have teaser component authored on my home page of demo.com website. After adding the the resource mapping and trying to access domo.com, it server tries to load image from below url and thus throwing 404 error:

https://demo.com_jcr_content/root/responsivegrid/responsivegrid_1471831795/responsivegrid_165…

If i try to access full URL for image then image is loading fine

https://demo.com/content/demo/us/en/_jcr_content/root/responsivegrid/responsivegrid_1471831795/respo...

Is there a way that shortening of these image paths can be ignored and rule only applies for webpages? Or else is there any other solution that can used here?

Below is sample resource mapping that I am using for demo.com.

{

    "jcr:primaryType": "sling:Folder",

    "demo.com": {

        "jcr:primaryType": "sling:Mapping",

        "sling:internalRedirect": [

            "/content/demo/us/en"

        ],

        "demo_com_content": {

            "jcr:primaryType": "sling:Mapping",

            "sling:match": "(.+)$",

            "sling:internalRedirect": [

                "/content/demo/us/en/$1",

                "/$1"

            ]

        },

        "reverse_mapping_content": {

            "jcr:primaryType": "sling:Mapping",

            "sling:match": "$1",

            "sling:internalRedirect": [

                "/content/demo/us/en/(.*).html"

            ]

        },

        "reverse_mapping_content_nohtml": {

            "jcr:primaryType": "sling:Mapping",

            "sling:match": "$1",

            "sling:internalRedirect": [

                "/content/demo/us/en/(.*)"

            ]

        },

        "reverse_mapping_root": {

            "jcr:primaryType": "sling:Mapping",

            "sling:match": "$",

            "sling:internalRedirect": [

                "/content/demo/us/en(.html)?"

            ]

        }

    },

    "demo_com_root": {

        "jcr:primaryType": "sling:Mapping",

        "sling:match": "demo.com$",

        "sling:internalRedirect": [

            "/content/demo/us/en.html"

        ]

    }

}

Replies

Highlighted

Gaurav-Behl

MVP

27-02-2019

Could you explain the purpose of using "reverse_mapping_content", "reverse_mapping_content_nohtml"  and "reverse_mapping_root". You could work with absolute urls on the server itself.

The other rules should suffice the requirement. The issue you're facing is because of "reverse_mapping_content_nohtml". You should not create a generic rule to map anything with "/content/demo/us/en/(.*)"

Remove two rules - "reverse_mapping_content_nohtml"  and "reverse_mapping_root" and test.

Highlighted

Gaurav-Behl

MVP

28-02-2019

https://demo.com/content/demo/us/en/_jcr_content/root/responsivegrid/responsivegrid_147183 1795/responsivegrid_165…  to    https://demo.com/content/demo/us/en/_jcr_content/root/responsivegrid/responsivegrid_147183 1795/responsivegrid_165…

happens with "reverse_mapping_content_nohtml" per shared rules.

After removing the rules, navigate to /system/console/jcrresolver and test your url/path using the 'map' feature

Could you share the rules in a package if you still run into issues?

Highlighted

rajeevy89244319

04-03-2019

Hi Gaurav,

Removing those 2 configurations is not fixing the issue. I checked resource resolver and both resolves to same path. But when I verify the Servlet resolver for long and short path, i notice that long path is being handled by adaptiveimageservlet as system is able to resolve the path to a resource while for short path it is not able to resolve to any resource so it tries to handle with DefaultGetServlet.

//=========================Long Path===========================================///

0 TIMER_START{Request Processing}

      1 COMMENT timer_end format is {<elapsed microseconds>,<timer name>} <optional message>

      3 LOG Method=GET, PathInfo=null

      4 TIMER_START{handleSecurity}

    784 TIMER_END{777,handleSecurity} authenticator org.apache.sling.auth.core.impl.SlingAuthenticator@363c58ed returns true

    991 TIMER_START{ResourceResolution}

   2076 TIMER_END{1077,ResourceResolution} URI=/content/demo/us/en/_jcr_content/root/responsivegrid/responsivegrid_1471831795/responsivegrid_1654523246/teaser.coreimg.png/1549341207212.png resolves to Resource=JcrNodeResource, type=demo/components/core/wcm/teaser, superType=null, path=/content/demo/us/en/jcr:content/root/responsivegrid/responsivegrid_1471831795/responsivegrid_1654523246/teaser

   2085 LOG Resource Path Info: SlingRequestPathInfo: path='/content/demo/us/en/jcr:content/root/responsivegrid/responsivegrid_1471831795/responsivegrid_1654523246/teaser', selectorString='coreimg', extension='png', suffix='/1549341207212.png'

   2086 TIMER_START{ServletResolution}

   2089 TIMER_START{resolveServlet(/content/demo/us/en/jcr:content/root/responsivegrid/responsivegrid_1471831795/responsivegrid_1654523246/teaser)}

   2104 TIMER_END{12,resolveServlet(/content/demo/us/en/jcr:content/root/responsivegrid/responsivegrid_1471831795/responsivegrid_1654523246/teaser)} Using servlet 59536

   2107 TIMER_END{20,ServletResolution} URI=/content/demo/us/en/_jcr_content/root/responsivegrid/responsivegrid_1471831795/responsivegrid_1654523246/teaser.coreimg.png/1549341207212.png handled by Servlet=59536

///==================Short Path =========================////

0 TIMER_START{Request Processing}

      1 COMMENT timer_end format is {<elapsed microseconds>,<timer name>} <optional message>

      5 LOG Method=GET, PathInfo=null

      6 TIMER_START{handleSecurity}

   1035 TIMER_END{1027,handleSecurity} authenticator org.apache.sling.auth.core.impl.SlingAuthenticator@363c58ed returns true

   1189 TIMER_START{ResourceResolution}

   1987 TIMER_END{796,ResourceResolution} URI=/_jcr_content/root/responsivegrid/responsivegrid_1471831795/responsivegrid_1654523246/teaser.coreimg.png/1549341207212.png resolves to Resource=NonExistingResource, path=/jcr:content/root/responsivegrid/responsivegrid_1471831795/responsivegrid_1654523246/teaser.coreimg.png/1549341207212.png

   1993 LOG Resource Path Info: SlingRequestPathInfo: path='/jcr:content/root/responsivegrid/responsivegrid_1471831795/responsivegrid_1654523246/teaser.coreimg.png/1549341207212.png', selectorString='coreimg', extension='png', suffix='/1549341207212.png'

   1993 TIMER_START{ServletResolution}

   1996 TIMER_START{resolveServlet(/jcr:content/root/responsivegrid/responsivegrid_1471831795/responsivegrid_1654523246/teaser.coreimg.png/1549341207212.png)}

   2716 LOG {0}: no servlet found

   2722 TIMER_END{723,resolveServlet(/jcr:content/root/responsivegrid/responsivegrid_1471831795/responsivegrid_1654523246/teaser.coreimg.png/1549341207212.png)} Using servlet org.apache.sling.servlets.get.DefaultGetServlet

   2724 TIMER_END{730,ServletResolution} URI=/_jcr_content/root/responsivegrid/responsivegrid_1471831795/responsivegrid_1654523246/teaser.coreimg.png/1549341207212.png handled by Servlet=org.apache.sling.servlets.get.DefaultGetServlet

Highlighted

rajeevy89244319

05-03-2019

Hi Gaurav,

I am unable to find an option to upload a file other than image and video. Could you please assist me on how the zip file can be uploaded in this editor.

Thanks,
Rajeev

Highlighted

Gaurav-Behl

MVP

06-03-2019

I checked the mappings but couldn't find a solution where you can shorten the url using sling mappings, avoid modifying teaser component and avoid using apache redirects for this use case.

Let's hear from other folks if they're aware of a better solution.