javascript - Change image path src to data-src on Drupal 7 -


i want use lazyload plugin. searched modules jquery plugin don't work me. moreover, use many options.

so, first rule:

latest version of lazy load not drop in replacement webpage. new browsers load image if remove src attribute javascript. must alter html code. put placeholder image src attribute of img tag. real image url should stored data-original attribute. thing can put javascript end of page. if want support non javascript browsers there step. must include original image inside tag. read documentation below.


but don't know how can this? possible javascript? or soluitons?

most images go through theme_image(), can override in theme's template.php file so:

function mytheme_image($vars) {   $attributes = $variables['attributes'];   $attributes['data-src'] = file_create_url($variables['path']); // <-- change here    foreach (array('width', 'height', 'alt', 'title') $key) {     if (isset($variables[$key])) {       $attributes[$key] = $variables[$key];     }   }    return '<img' . drupal_attributes($attributes) . ' />'; } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -