Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No image preview, querySelector used in fetchImage is null #12

Open
Chadys opened this issue Jun 18, 2024 · 0 comments
Open

No image preview, querySelector used in fetchImage is null #12

Chadys opened this issue Jun 18, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Chadys
Copy link

Chadys commented Jun 18, 2024

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>
@rinti rinti added the bug Something isn't working label Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants