Issue with teaser images with resource mapping | Community
Skip to main content
rajeevy89244319
Level 3
February 27, 2019

Issue with teaser images with resource mapping

  • February 27, 2019
  • 3 replies
  • 24958 views

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/responsivegrid_165…

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"

        ]

    }

}

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

Gaurav-Behl
Level 10
February 28, 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.

rajeevy89244319
Level 3
February 28, 2019

Tried deleting those 2 entries but no luck. Still same behavior.

Gaurav-Behl
Level 10
February 28, 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?

Bharath_valse
Level 4
February 11, 2020

Rajeev, did you get to closure on this scenario? If yes, please share the same with us.

Bharath_valse
Level 4
February 13, 2020

Was able to get the redirects to work for both content URLs and teaser image URLs. Below are few rules from my local instance

 

{
  "jcr:primaryType": "sling:Folder",
  "jcr:createdBy": "admin",
  "hidden": "true",
  "jcr:created": "Tue Sep 17 2019 15:26:49 GMT-0700",
  "http": {
    "jcr:primaryType": "sling:Folder",
    "jcr:createdBy": "admin",
    "jcr:created": "Tue Sep 17 2019 15:26:49 GMT-0700",
    "localhost.4508": {
      "jcr:primaryType": "sling:Mapping",
      "jcr:createdBy": "admin",
      "jcr:created": "Thu Feb 13 2020 12:18:43 GMT-0800",
      "sling:internalRedirect": "/content/we-retail/us/en",
      "redirect": {
        "jcr:primaryType": "sling:Mapping",
        "jcr:createdBy": "admin",
        "jcr:created": "Thu Feb 13 2020 12:18:43 GMT-0800",
        "sling:match": "(.+)$",
        "sling:internalRedirect": [
          "/content/we-retail/us/en/$1",
          "/$1"
        ]
        }
      }
    }
  }