Overriding rails_amp image helper to cater for lazy-loaded images
One of it’s features is automatically converting the
image_tag into the AMP compatible alternative.
The affiliate site however has lazy loading that uses jQuery lazy which means that instead of:
it mostly uses:
rails_amp gem then generates the AMP image tag for the placeholder image only.
To solve that the image tag helper
rails_amp can be overriden like this:
data[src] is present the source is overriden. Otherwise it functions the same as for regular image tags.
Get in touch
Or send me feedback. It will take less than 20 seconds.