wagtail-meta-preview
wagtail-meta-preview copied to clipboard
No image preview, querySelector used in fetchImage is null
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:
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>