wagtail-meta-preview icon indicating copy to clipboard operation
wagtail-meta-preview copied to clipboard

No image preview, querySelector used in fetchImage is null

Open Chadys opened this issue 8 months ago • 0 comments

In fetchimage, the code call

const baseAdminUrl = document.querySelector("a.logo").getAttribute('href');

But in the last wagtail version (I don't know when this has changed), there is no logo class but a sidebar-wagtail-branding instead, see screenshot: Screenshot wagtail_admin The preview of the image does not work then.

Instead of relying on a css class that might change anytime, wouldn't it be more robust to get the image's url from the "#id_" + field + "-chooser" element? See the following template extract:

<div id="id_og_image-chooser" class="chooser image-chooser" data-chooser-url="/cms-admin/images/chooser/">
    <div class="chosen">
    <img class="chooser__image" data-chooser-image="" alt="" decoding="async" height="" src="/media/images/img_name.jpg" width="165">
{# ... #}
</div>
</div>

Chadys avatar Jun 18 '24 17:06 Chadys