The module is a "responsive lazyloader". There is no device detection but use of mediaqueries.
That mean it will load on scroll the best apropriate image style according to the current breakpoint &/or display. (small image on sidebar, medium in content as exemple)

This module allow you to use real complex mediaqueries as retina display detection or orientation recognition. (what i was not able to do with the contrib modules I've tested).
There is no dependancies to the image field but realy to the position of the image in the page layout & to the mediaquery.

I hope my UI is pretty clear and make the config of the module as simple as possible.
The module is pre-setup with basic settings.

For now this is a Drupal 7.x module.

Features :
A simple lazy loader.
A custom lazy loader to load specific image style according to html structure.
A custom lazy loader to load specific image style according to current media query.
A custom lazy loader to load specific image style matching the html structure and the media query.
Load image only when the image is on the active window.

Available Settings :
Enable / disable the lazy loader.
Set the distance between the image and the active window to triger le image loading.
Exclude some pages from the lazy loader.
Configure the breakpoints (media queries)
Configure the layouts.
Advance features as javascript actions on image load or after all images load (as for custom analytics action).

Some debug code is available on the UI to help users ton configure the module. (see : advance settings)

It works with AJAX
The plugin already used with views using ajax and views infinite scroll.

Learn more
To learn more about responsivelazyloader look at the jQuery plugin http://plugins.jquery.com/responsivelazyloader/

From my point of view, this module is not a duplicate of the following ones :
https://drupal.org/project/cs_adaptive_image
https://drupal.org/project/rwdimages
https://drupal.org/project/lazyloader

The module use a jQuery plugin i've published on MIT & GPL licence.

I've already made a "coder" check of the code with success and made some manual reviews from the Drupal gidelines.

This is the sandbox link : https://drupal.org/sandbox/jetmartin/2158105

This is the link to the GIT :
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/jetmartin/2158105.git responsivelazyloader
cd responsivelazyloader

I've previously never contributed to Drupal but it's never too late to start. I hope this module could be usefull for others peoples.
Thank you for spending some of you'r time to review my code.

Comments

PA robot’s picture

Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxjetmartin2158105git

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

jetmartin’s picture

Status: Needs work » Needs review

I've made the code review and some updates as the use of librarie to load the external jQuery plugin.
I still have on issue with http://pareview.sh/ about the readme file.
I guess i read in another Drupal documentation, to wait for the project application to write this file.
So i wait for feedback.

arlina’s picture

Hi jetmartin,

Looks like an interesting module. I see you almost pass PAReview! Some pointers:

  • You should add the README.txt file to your module, detailing how to use and install (dependencies, etc.). Don't wait until your application is approved, as it gives us all more info on your module.
  • When configuring your module on a fresh D7 installation, it says $conf['image_allow_insecure_derivatives'] = TRUE; must be added to settings.php. You should add that to the installation instructions as well.
  • On responsivelazyloader_process_html() it basically adds an inline javascript to $vars['page_bottom'], but that way Drupal can't take advantage of js aggregation. Perhaps you can split your code in two to fix this:
    1. A settings part, and add it to Drupal's settings javascript object:
      drupal_add_js(array('responsivelazyloader' => $your_settings_array), 'setting');
    2. A regular javascript file, where you retrieve your module's settings by using Drupal.settings.responsivelazyloader.

    That should allow aggregation while using variable settings.

I'll keep testing your module and giving you feedback.

arlina’s picture

Status: Needs review » Needs work
arlina’s picture

Your post also lists your personal git URL, change it to your public git clone command:

http://git.drupal.org/sandbox/jetmartin/2158105.git

jetmartin’s picture

Thank's a lot for you'r review ! (sorry for the delay of answer)
I'm glad to see that you find it interesting.

I've also think to this JS aggregation solution but to be honest some contrib plugin do it this way so I was lazy...
You'r right i will fix that.

I'm also updating the jQuery plugin, now the parent is optional if it match with the display class.
So i will made some updates to make the config easier.

I'll made the updates very soon.

jetmartin’s picture

Issue summary: View changes
jetmartin’s picture

Status: Needs work » Needs review

Hi.

I've made some major changes yesterday.
I've completely remove the hook_process_html(). It's much cleaner now, thank you. I've made some testings using AJAX, aggregation & caching...

I've added a readme file and the requirement instruction about the image insecure derivatives on the project page.
I've also made some UX updates on displays.

I hope the module is in a good shape now.

I do not added a check on the jQuery plugin release even if the plugin need a >0.1.4 release for now.
I assume there is not really a chance for a new user to download an old release.

Thank you for reviewing the module.

rmn’s picture

Status: Needs review » Needs work

Hi

Please rename readme.md to README.md. It's even showing up as en error in pareview.sh.
Verify there are no comments/errors on pareview before changing the status further.

Thanks
Raman

jetmartin’s picture

Status: Needs work » Needs review

Hi.

Sorry, my mistake.
pareview.sh is now fine : http://pareview.sh/pareview/httpgitdrupalorgsandboxjetmartin2158105git

I've also :
- Added the hook_help.
- Updated the code with some early users feedback.

rmn’s picture

Status: Needs review » Needs work

Hi

Under the file responsivelazyloader.init.js.

    /* Lazy Loader init. */
    $("img[data-src]").responsivelazyloader();
    /* Lazyloader init after AJAX call if jQuery>=1.7 */
    var arr = $.fn.jquery.split('.');
    if(arr[0] > 1 || (arr[0] == 1 && arr[1] > 7)){
      $("body").on({ ajaxStop : function(){ $("img[data-src]").responsivelazyloader(); }});
    }
  1. The comment and code mismatches, the comment is for jQuery >= 1.7 while the if condition only validates for jQuery > 1.7.
  2. Also, I tested with jQuery 1.8 and the ajaxStop doesn't fire. Please add it to document instead of body, see the additional notes section on this page. You can also refer to the answer here.
  3. Also, for jQuery > 1.7, wouldn't the call be made twice? Once above the if statement and one inside the if statement? Or am I missing something?

Thanks
Raman

jetmartin’s picture

Status: Needs work » Needs review

Hi.

Thank's rmn for the review and advises.
Now, i've updated the code according to the jQuery doc using $(document).ajaxStop();
So i've tested it with a brand new Drupal install and with an update to jQuery 1.8, it's works in both cases.
No more need of check the jQuery release.

To answer your last question, the second call is used for set the LazyLoder on AJAX event.
Without this call, the images loaded by AJAX such as views AJAX, views infinite scroll, the cTools Modal, ... will never be loaded.

Regards

J-Et. MARTIN

plazik’s picture

Status: Needs review » Needs work

You should name folder with module responsivelazyloader as your responsivelazyloader.module file.

You should rename README.md to README.txt. It's a standart for Drupal.

responsivelazyloader.info:
Some typos:
description = Enable a full configurable responsive lazyloader. You cand create custon configuration for any CSS grid system.

stylesheets[all][] = css/responsivelazyloader.css
scripts[] = js/responsivelazyloader.init.js

These files is added to all pages including page where they are not using. You shoud add it via drupal_add_js() and drupal_add_css() in .module file.

responsivelazyloader.module

define('RESPONSIVELAZYLOADER_MODULE_PATH', base_path() . drupal_get_path('module', 'responsivelazyloader'));

You are using it only once. Are you sure it should be a constant?

Hook_init(). should be Implements hook_init().. Also everywhere.

  // Load the jQuery plugin if available.
  if (module_exists('libraries')) {
    $path = libraries_get_path('responsivelazyloader');
    if (file_exists($path . '/jquery.responsivelazyloader.js')) {
      drupal_add_js($path . '/jquery.responsivelazyloader.js');
    }
    if (file_exists($path . '/jquery.responsivelazyloader.min.js')) {
      drupal_add_js($path . '/jquery.responsivelazyloader.min.js');
    }
  }

These files also is added to all pages.

'#markup' => '<noscript><style type="text/css" media="all">img[data-src] { display: none; }</style></noscript>',
See the proper version of adding noscript tag https://drupal.org/comment/6840288#comment-6840288

responsivelazyloader.admin.inc

/**
 * @file
 * ResponsiveLazyLoader Admin.
 */

It should be like this:

/**
 * @file
 * Code for admin pages for ResponsiveLazyLoader module.
 */

"JQuery responsivelazyloader must be installed" should be "jQuery responsivelazyloader must be installed".

lukus’s picture

Hey - this module looks great. Can't wait for a release.

I'll check out the module in the meantime and provide any feedback that comes to mind.

Thanks :)

Luke

jetmartin’s picture

Hi.

I will have some free time this week or next one.
I will made the update as soon as possible, thank you Plazik for this complete review.
@Lukus : thanks for the nice feedback !

J-Et.

jetmartin’s picture

Issue summary: View changes
jetmartin’s picture

Status: Needs work » Needs review

Hi.

I've made the code updates.
I've made some basics tests with & without caching & aggregations.
The new JS implementation looks fine.

I wait for you'r feedbacks.

Regards.

J-Et.

BigEd’s picture

Status: Needs review » Needs work

Hi JetMartin,

Wow a great module you have here I am looking forward to seeing this in the wild.

I checked and there are no issues from http://pareview.sh, however there are some small things I picked.

  • It's a small thing but on line 107 & 113 you have a line break in the t( I think for consistency it would be better not to break lines here.
  • Extra space on line 16 of .install
  • Again a small thing I know but there is quite a few punctuation and spelling issues in the read me file. I can list if you are struggling but there was quite a few I could see.

They are small things and can be quite frustrating but it looks like you are quite close. I need to go through this again in a bit more detail later to see if I can spot anything that might be an issue.

Great work!

jetmartin’s picture

Hi BigEd.

Thank you :D

So, i've made the minor fix you'r asking for.

The fact is i'm not english native so if you could help for the readme file ? i'll really appreciate your help !

Regards.

PS : I will be on vacation with no internet connection in the coming days, don't worry i i do not answer before the 22th of april.

PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application (see also the project application workflow).

I'm a robot and this is an automated message from Project Applications Scraper.

lukus’s picture

Hey ... any more news on this app?

Hope your vacation was good.

L

jetmartin’s picture

Hey.

Sorry, but I woudn't post a single "UP"...

I've not enough english friends here to help me on that review.
So if anyone would like to help me to review my poor english i will really apreciate your help !
So we could end this application process.

As BigEd said it's not a big deal just "quite a few punctuation and spelling issues in the read me file".

In advance thank you to the one who will spend some of his time on this to help ! I will also ask again on my side...

Thank you Lukus, seeing someone following the project reboost myself :)

J-Et.

jeroent’s picture

Status: Closed (won't fix) » Needs review

I recently created a patch for this module in which I reviewed the spelling issues (https://www.drupal.org/node/2298185).

If BigEd or someone else could review this module again and eventually make a list of the remaining spelling and punctuation issues, that would be great!

SGhosh’s picture

Hey,



Following is the review -

Automated Review

pareview.sh still identifies a few errors and warnings. Please go through them here - http://pareview.sh/pareview/httpgitdrupalorgsandboxjetmartin2158105git

Manual Review

No duplication
No: Does not cause module duplication and fragmentation.
Master Branch
Yes: Follows the guidelines for master branch.
README.txt/README.md
Yes: Follows the guidelines for in-project documentation and the README Template.
Coding style & Drupal API usage
  1. Permissions are not really required for this functionality. It should be only available to the admin to set or not once and for all for the entire site.

Good module, serves the purpose well. Though for future development(after release) you could make application of this functionality configurable like field/image formatters.

This review uses the Project Application Review Template.

jetmartin’s picture

Thank you for the review !
I will fix this very soon.

jetmartin’s picture

Hi.

I've fix the issues on pareview.sh.
I guess this time it could be good.

Thank yout for the idea of field/image formatter. May we could discuss about that and more at DC Amsterdam if you go there.

Regards

J-Et.

codesidekick’s picture

Manual Review

README.txt/README.md
No: does not follow the README Template but README file is present.
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Security
No. image_allow_insecure_derivatives is a requirement of the module, why? Is there a way we can go around this by generating image style derivatives on the server side and using Drupal javascript settings to inject the paths? This is a security issue, and opens any site using this module up to a DDOS style attack. I think this alone would be reason enough for people not to install this module on their site as providing a lazy loader at the expense of opening a site up for attack doesn't seem worth it. If you would like help with making this module not have to bypass derivative security then I can help, just let me know why it's required at the moment (what piece of code is being broken).
Coding style & Drupal API usage
List of identified issues in no particular order:
  1. (+) The security issue mentioned above
  2. (+) responsivelazyloader.init.js do not use document.ready, use Drupal behaviors. In the current state the module breaks with any AJAX loaded content but using Drupal behaviors this will no longer be an issue. Please review the Behaviors section of https://www.drupal.org/node/756722 - its basically like doing a document.ready however you're doing it on every request and sub-request and you have access to changing Drupal.settings when AJAX commands make modifications.
  3. (+) Indenting for arrays / array values is different from how Drupal core and contrib modules are usually written. For example in hook_menu the items array, the array values are all lined up. Though this is accepted in some other frameworks this is not commonplace in Drupal and makes it difficult for other maintainers or patches to contribute.
  4. (*) Weight of module is excessive and prevents any modules from overriding it. If there is a specific module causing problems then mention it here, otherwise reduce the weight to something more sensible like 100. You can see a common list of module weights at https://www.drupal.org/node/110238. One of the uniquely awesome things about Drupal is that modules can override each other.

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.

This review uses the Project Application Review Template.

Great work otherwise, I can really see potential for this module. My only real concern is the security issue and I think we can fix that.

codesidekick’s picture

Status: Needs review » Needs work
jetmartin’s picture

Hi.

Thank's a lots for this detailed review and the nice feedback.
I will re-think about the image derivatives and others stuff you reviewed after the new year.
I'll keep you in touch, even more if i need somme help to fix any issue.

I wish you an happy new year !

J-Et.

PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).

I'm a robot and this is an automated message from Project Applications Scraper.

lukus’s picture

Hi, any update on this? I'd be happy to help out if I can.