adobe / aem-core-wcm-components

Standardized components to build websites with AEM.
https://docs.adobe.com/content/help/en/experience-manager-core-components/using/introduction.html
Apache License 2.0
746 stars 753 forks source link

404 fetching page image thumbnail when authoring page properties #2816

Open HitmanInWis opened 4 months ago

HitmanInWis commented 4 months ago

Bug Present as of Version: 2.25.5-SNAPSHOT

When opening Page Properties there are requests to the server that result in HTTP 404 (Not Found) in the browser console. The URL looks like this: http://localhost:4502/mnt/overlay/wcm/core/content/sites/undefined.htmlundefined

This is coming from updateImageThumbnail in image.js - the function assumes we are in an actual image dialog (looking for the .cmp-image__editor selector) and attempts to fetch the page image. Since the selector is not present, thumbnailConfigPath and thumbnailComponentPath end up null, and thus the fetch of undefined.htmlundefined

HitmanInWis commented 4 months ago

Potential solution is to simply check if $(dialogContentSelector) is found, if not, exit the updateImageThumbnail function.

Note that the thumbnail for the featured page image is still correctly showing (it is loading via standard image widget functionality) so this error is not technically preventing authors from doing anything they need to do.

HitmanInWis commented 4 months ago

Here's the solution that I believe is working for me.

Change the following code within updatePageImageThumbnail() in image.js

        var thumbnailConfigPath = $(dialogContentSelector).find(pageImageThumbnailSelector).attr(pageImageThumbnailConfigPathAttribute);
        var thumbnailComponentPath = $(dialogContentSelector).find(pageImageThumbnailSelector).attr(pageImageThumbnailComponentPathAttribute);

to

        var thumbnailElement = $(dialogContentSelector).find(pageImageThumbnailSelector)
        if (thumbnailElement.size() === 0) {
            return Promise.resolve();
        }
        var thumbnailConfigPath = thumbnailElement.attr(pageImageThumbnailConfigPathAttribute);
        var thumbnailComponentPath = thumbnailElement.attr(pageImageThumbnailComponentPathAttribute);