The Imgfly module delivers on-the-fly images for responsive layouts with minimum configuration. The module uses a javascript code that determines the width of the parent element that holds the image and thus requests an image that will be dynamically generated to requested size. For optimal performance you need to have a reverse proxy caching mechanism on your site like Varnish or Squid to cache and deliver the dynamically generated images.

Project page

http://drupal.org/sandbox/thamba/1988992

Git repository

git clone http://git.drupal.org/sandbox/thamba/1988992.git imgfly

Reviews of other project applications

Comments

ethant’s picture

Hey thamba. I'm confused - what does this module do that isn't already accomplished with css "img{max-width:100%}"?

I activated this module, added an image style with the "_imgfly" suffix, and made sure it was set to scale and crop - I also have images set to max-width:100%. I set the size to 500x500, but didn't see that the effect was any different when I resized, than with plain css. Apologies if I'm doing something incorrectly.

Maybe modify your script to add states to Drupal.settings, and serve different image_cache styles based on screensize?

thamba’s picture

Hi EthanT,

Thanks for testing the module out.
This module does not refresh the image on browser resizing. So if you resized your browser window, you probably have to refresh your page to see the changed image. Resizing browser windows is not something people do much so we have ignored to refresh pages on window resize at the moment. This is because that should really be handled by the theme.

The image will be scaled down to exactly the right proportions and delivered dynamically without Drupal having to save it to disk. This is also useful in applications where you need to programatically add image tags with specific sizes without having to create so many different image styles.

ethant’s picture

Gotcha - now I see it.

I do a lot of themeing for responsive sites, and we generally fire responsive js scripts not only on window load / page ready, but also on resize. It would be pretty easy to add your image function to jQuery's resize().....but I hear what you are saying.

stefan lehmann’s picture

Hello there!

The automatic review says, that your module is clean. :-)

Manual review of 7.x-1.x branch:

  • imgfly.admin.inc, LINE 31, maybe add a text, that you expect the dimension in the format 100x100.
  • imgfly.module, LINE 55, I think it would be better to use boolean values here.
  • imgfly.info, I think modules working with images would normally go into the package = Media

I know, that you are already handling it to some point by restricting the image size to a certain dimension, but as far as I understand it your module could still easily be exploited to attack a server. A possible attacker could just go through all permutations of image dimensions and let your script render these images. Not sure, if it's worth fixing and if there is an easy way to avoid this, though. :-)

brice_gato’s picture

Hello @thamba,
Your project is interesting and andmore your code is clean.
In addition to optimization remarks from @Stefan Lehmann I add this :
LINE 119 : Add a test before your stock variable
$itok = isset($_GET['itok']) ? trim($_GET['itok']) : '';

thamba’s picture

Thanks Stefan Lehmann and brice_gato. I have now added the fixes you have suggested.

klausi’s picture

Assigned: Unassigned » sreynen
Status: Needs review » Reviewed & tested by the community
Issue tags: -PAreview: review bonus

manual review:

  1. please also mention the differences to the existing projects on your project page.
  2. imgfly_generate(): @return resource: what resource is returned? The function does not return anything? See http://drupal.org/node/1354#return
  3. imgfly_admin(): all variables defined by your module need to be removed in hook_uninstall().

But otherwise looks RTBC to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

Assigning to sreynen as he might have time to take a final look at this.

thamba’s picture

Thanks klausi. Fixed and committed.

thamba’s picture

Issue tags: +PAreview: review bonus

Adding 3 additional links to reviews of other project applications I recently did.

sreynen’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for your contribution, thamba !

I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and get involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider continuing to review other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewers as well.

thamba’s picture

Thank you!

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Adding 3 additional reviews of other project applications.