collective / collective.lazysizes

Integration of lazysizes, a lightweight lazy loader, into Plone.
https://pypi.org/project/collective.lazysizes
6 stars 2 forks source link

KeyError on images withour src attribute #11

Closed hvelarde closed 8 years ago

hvelarde commented 8 years ago

Seems that under some weird circumstances there can be img tags without src attributes; we need to gracefully handle this exception and point to the object responsible of this situation:

2016-04-06T01:18:39 ERROR plone.transformchain Unexpected error whilst trying to apply transform chain
Traceback (most recent call last):
  File "/home/cartacapital/cartacapital.portal.buildout/eggs/plone.transformchain-1.0.3-py2.7.egg/plone/transformchain/transformer.py", line 48, in __call__
    newResult = handler.transformIterable(result, encoding)
  File "/home/cartacapital/cartacapital.portal.buildout/eggs/collective.lazysizes-1.4.0a1-py2.7.egg/collective/lazysizes/transform.py", line 103, in transformIterable
    self._lazyload(el)
  File "/home/cartacapital/cartacapital.portal.buildout/eggs/collective.lazysizes-1.4.0a1-py2.7.egg/collective/lazysizes/transform.py", line 57, in _lazyload
    element.attrib['data-src'] = element.attrib['src']
  File "lxml.etree.pyx", line 2200, in lxml.etree._Attrib.__getitem__ (src/lxml/lxml.etree.c:49210)
KeyError: 'src'