dan-gamble/django-lazy-image

Setting `show_small_image` to False breaks LazyImage for the whole page

danielsamuels opened this issue · 2 comments

Disabling show_small_image results in the small image element not being output, as expected:

{% if show_small_image %}
<img class="img-Image_Image img-Image_Image-small img-Image_Image-loaded{% if blur %} img-Image_Image-blurred{% endif %}" alt="" src="{{ small_image_url }}">
{% endif %}

However, the JS will still try and remove this element, regardless of whether it exists or not:

if (evt.propertyName === 'opacity') {
this.smallImage.parentNode.removeChild(this.smallImage)
}

I think the above condition just needs to be changed to this:

if (evt.propertyName === 'opacity' && this.smallImage) {

Had to recently do this on CSP. Will fix it now 👍

This is live under 0.3.2 now. (Pypi and npm)