airfranceklm / ng-lazy-image

Angular directive for loading responsive image when container (which is preventing reflow) is in viewport.
http://afklm.github.io/ng-lazy-image/
MIT License
351 stars 64 forks source link

Add option to add custom attributes in appened image directive #37

Closed MichaelTSS closed 8 years ago

MichaelTSS commented 8 years ago

Use case examples:

<div class="afkl-lazy-wrapper afkl-img-ratio-1-1"
afkl-lazy-image="{{profile.avatar_url}}"
afkl-lazy-image-options="{'background': false, imgAttrs: [{'onerror': 'this.src=\'/img/person-avatar.png\''}]}">
</div>
<div class="afkl-lazy-wrapper afkl-img-ratio-1-1"
afkl-lazy-image="{{profile.avatar_url}}"
afkl-lazy-image-options="{'background': false, imgAttrs: [{'title': '{{profile.title}}', 'data-id': '{{profile.id}}'}]}">
</div>

For backwards compatibility reasons, the alt option shout be kept but imgAttrs obviously support that.

SquadraCorse commented 8 years ago

Thanks MichaelTSS!