I ran page speed against my site which is running image captcha. It said that to increase rendering speed image dimensions should be used.
http://code.google.com/speed/page-speed/docs/rendering.html#SpecifyImage...
I don't know if Captcha uses a fixed image size or not, I wasn't able to find an image size value in the settings.
I have attached a patch specifying the sizes which I believe to be static.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | image_captcha(978530)_2.patch | 3 KB | elachlan |
| #5 | image_captcha(978530)_1.patch | 2.89 KB | elachlan |
| #3 | image_captcha(978530).patch | 2.68 KB | elachlan |
| image_captcha.module.patch | 918 bytes | elachlan |
Comments
Comment #1
elachlan commentedOn closer inspection I found that the code length changes the width.
I see the $code_length attribute in image_captcha.module line 207
The change would be at line 223.
I was thinking something along the lines of:
I tested it and it doesn't work. Not sure how to fix it. I think I have to make sure $code_length is an int then convert both back to a string.
Comment #2
soxofaan commentedGood idea, but hardly a bug, more a feature request.
Anyway, this is the code that defines the image size (see function
_image_captcha_generate_imagein image_captcha.user.inc:For this issue, I would recommend to factor this code out in a function like
image_captcha_image_size()and then use this function in_image_captcha_generate_image()and inimage_captcha_captcha()Comment #3
elachlan commentedPatch with changes.
Comment #4
soxofaan commentedthat's fast :)
I didn't try the patch yet (only read it), but here is just a tip to make the code cleaner:
Also, the patch seems to introduces tab instead of spaces for indentation in image_captcha.module.
Comment #5
elachlan commentedChanges :)
Hopefully fixed!!
Comment #6
soxofaan commentedthanks for the update.
some remarks
in image_captcha_image_size:
-
$fonts = _image_captcha_get_enabled_fonts();is not needed I think-
$codeis used but not defined, there must be something wrong here.in _image_captcha_generate_image: still using $arr['width'] instead of list(width, ...)
Comment #7
elachlan commentedHopefully Fixed!!!
Changes it so that it requires the $Code parameter.
The code needs better comments, its hard to understand some of it.
Comment #8
soxofaan commentedHi elachlan,
I reworked your patch a bit: renamed to function "_image_captcha_image_size" (with leading underscore), moved it to image_captcha.module (from image_captcha.user.inc) and added a bit more documentation.
Committed: http://drupal.org/cvs?commit=456624
thanks for your work
Comment #9
elachlan commentedLove your work soxofaan! Thanks!