Image captcha doesn't display the CAPTCHA image, instead displays alt text from corresponding img tag
Sandymaguire - February 25, 2009 - 10:50
| Project: | CAPTCHA |
| Version: | 6.x-2.0-rc3 |
| Component: | Image Captcha (image_captcha) |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Jump to:
Description
I installed CAPTCHA module.
The image CAPTCHA works fine on my localhost...
When i upload the same module to the server, Instead of the CAPTCHA image it's displaying "image CAPTCHA" which is the alternative text in the img tag...
Text CAPTCHA and Math CAPTCHA are working well..
Having this pending for a long time.
Pls help..
thank u

#1
Reassigning to the proper queue (guessing the version)
- Arie
#2
I guess that the version is 6.x-1.0-rc2 (not 6.x-2.x)
it works on your localhost setup, but it doesn't work on your hosting server: what are the differences between the two?
#3
i installed captcha module on the site on localhost, captcha image displays..
When i did the same on the site hosted online.The captcha image is not displaying.Instead displays text "image CAPTCHA"
#4
#3 does not add extra information compared to the original post. Please provide more information, otherwise I can't help.
Provide version numbers (PHP, Drupal, CAPTCHA module, etc), other installed modules, hosting setup information, on which kind of forms do you enable CAPTCHAs, etc ...
#5
Hi
PHP5
Drupal 6.9
Captcha module CAPTCHA 6.x-1.0-rc2
Other installed modules are..
abuse
CCK
Contact Forms
ddblock
email
feedapi
feedapi_mapper
flickr
image
jquery_update
link
profile_category_weight
terms_of_use
Views
webform
I have enabled image captcha in user_register ie the registration form.
#6
what happens if you request the image URL directly (right click on the
alt text and choose something like "open image" or "view image",
depending on your browser)?
what browser are you using (firefox, opera, safari, internet explorer)?
#7
have you tried running cron and checking if the image shows afterwards?
#8
Hi
#6 when i right click and do view image a black scree opens up... the url is like
http://www.example.com/myproject/image_captcha/624106399
actually the module renders the
the image doesnt come instead the alternative text is coming..
#7
yes i did cron still the same prob persists..
ty
#9
I'm having exactly the same issue with Captcha (6.x-1.0-rc2) on Drupal 6.9. I just upgraded to Drupal 6.9 from 6.8. Image CAPTCHA was working fine on Drupal 6.8. My contact form Image CAPTCHA image and the Image CAPTCHA examples produce the same behavior, i.e., the image is replaced with the allternate text "Image CAPTCHA". Also ran cron manually which had no effect on this Image CAPTCHA behavior.
#10
ok...should have tried this first but it seems one always overlooks the obvious. I re-uploaded my font for Image CAPTCHA to /sites/all/modules/captcha/image_captcha/fonts and everything is working fine....doh!
#11
Hi can stanb be more specific about the contents of /sites/all/modules/captcha/image_captcha/fonts .
I have nothing but a readme.txt file and it says install ttf files.
I tried putting some fonts like Grantham Bold.ttf
Still the same prob persists...
Pls help.
#12
For ppl who get the alt text displayed instead of the captcha image.
This may sound as a rubbish solution.... But for not it worked great for me.
replace
$result['form']['captcha_image'] = array(
'#type' => 'markup',
'#value' => '',
'#weight' => -2,
);
on line 139 on image_captcha.module with the following
$result['form']['captcha_image'] = array(
'#type' => 'markup',
'#value' => 'http://www.istockphoto.com/file_thumbview_approve/1883946/2/istockphoto_...); background-image:url(http://www.example.com/pine-wood-texture.jpg); display:block; height:40px; text-align:center; width:100px;">',
'#weight' => -2,
);
1.U are setting the alternative text alt= "'.t('image CAPTCHA') with alt="'. t($code).
2.Strike through the text.
3.Also display a background image behind the code.
#13
@Sandymaguire: After putting the ttf file into the font directory, you should select it in the image captcha settings. Otherwise the font won't be used.
#14
I have exactly the same issue, since 6.9 Captcha's images are broken.
After several investigations, it appears that drupal, since 6.9 (and still in 6.10) adds 3 headers lines to any page, including the jpeg image of Captcha, so corruping the jpeq response content ...
A work-arround, is to empty the response buffer in the hook_init of mymodule (or any module you could change), as follow:
<<
function mymodule_init() {
// CAPTCHA FIX: empty output buffer for captcha image generation.
if (substr($_GET['q'],0,14) == 'image_captcha/') ob_clean();
}
>>
May i suggest to include a call to ob_clean() in the function image_captcha_image($seed=NULL) ?
On the drupal side, who knows which mymodule's code could be call before mymodule_init() ?
#15
at #14: I can't reproduce your findings on my Drupal 6.10 setup, so I don't think those three header lines are from Drupal core.
I assume the problem lies in one of the contrib modules you installed.
can you check this?
#16
Ooups ! I finaly find : some of include files of my module have the ?> tag plus an empty line at the end. That's the way empty lines came into the page before the call to mymodule_init() ! The empty line was copied to the output ...
I saw that Drupal's code have not end tag at all and that many people accept it as a good practice ... That's just a problem if you use a XMLEditor.
#17
Indeed. For those interested: in PHP the closing
?>is optional and not using it is recommended/best practice in Drupal code.(Edit: better wording of what I wanted to say)
#18
I ran into this same problem using Drupal 6.10 and image captcha 6.x-2.0-beta3. After reading this page I went back and checked my custom modules, sure enough I'd left a closing ?> followed by blank lines at the bottom of one of my (unrelated) modules and after removing that the image captcha image came back.
#19
true,
solved here also, maybe more than one empty line at the end could lead to this, even if closing ?> does not exist
#20
I spend a fair amount of time chasing this bug in one of my sites. My problem was originally not getting the image captcha, then when I switched to math captcha for testing I was getting a captcha token invalid message.
I had deleted user 0 during a cleanup of users from extensive testing for code that automatically creates new users. I deleted all but admin (user 1). Restoring user 0 solved my problem. The weird thing is that all non auth users were getting sessions, but never seemed to get captcha data in those sessions.
Found the answer in another thread related to the invalid token, but wanted to pass it on. This solved my problem without any code modifications.
Drupal 6.12
Captcha 6.x-1.0-rc2
All browsers.
#21
Hi everyone,
I have same problem (it works great into a WAMP framework, but it doesn't run into a Linux environment), without inconsistency in user table.
So, are there other causes for non-working image captcha?
Drupal 6.13
6.x-2.0-rc2
#22
this thread discusses several other causes too: see #6, #14-#17
#23
@#6:
with IE (clicking on broken image link --> view link/open page http:///image_captcha/82/1247476990): the web page cannot be rendered.
with Firefox (clicking on alt text --> view link/open page): blank page.
@#14 & @#17:
I have no custom module. How (and where) should I apply that solutions? How can you be confident that different php code (closing tag and/or a patch) can solve this issue in a Linux environment, whereas in a WAMP env. all is working great?
#24
@Alex72RM: what do you get when you download the image url with "wget" under linux/osx?
Or if you are not familiar with wget and the site is publicly accessible: send me the link through my contact form
#25
@Alex72RM: I got your message and tried the link, but the request for the image returns nothing
$ wget http://example.com/image_captcha/89/12474--12:11:10-- http://example.com/image_captcha/89/12474
=> `12474'
Resolving [snip]
Connecting to [snip] ... connected.
HTTP request sent, awaiting response... No data received.
Retrying.
so it's not the problem of #14-#17
Another possible reason is that your linux PHP setup has no support for the imagejpeg function. Did you build the site on one setup (with imagejpeg support) and then moved it to that linux setup (possibly without imagejpeg support)? For more info see #205525: Images cannot be generated, because your PHP installation's GD library has no JPEG support. you can also get more information about your setup at example.com/admin/logs/status/php (there should be something like "--with-gd", GD is the PHP image handling library)
#26
Hi again,
phpinfo() tell me that gd is all ok.
Freetype support: enabled
Freetype linkage: with freetype
JPG Support: enabled
#27
Getting same problem ....
#28
Please provide more info than "getting the same problem". If that's all you give me, I can't help you.
e.g.:
which version of drupal, captcha module?
what's your webserver setup (linux? php version?)
does the image work on the image CAPTCHA admin page? does it work for authenticated users?
are there related error messages in the drupal log, webserver log or php log?
do you have a uid=0 in your users table? (which is common source for problems in CAPTCHA 5.x-3.x and 6.x-1.x, see http://drupal.org/project/issues/search/captcha?issue_tags=captchauid0)
#29
Hi again,
I hope my response could be useful.
which version of drupal, captcha module?
6.13, 6.x-2.0-rc2
what's your webserver setup (linux? php version?)
Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7| DAV/2 PHP/5.2.6 Phusion_Passenger/2.0.5
does the image work on the image CAPTCHA admin page? does it work for authenticated users?
It doesn't work at all, for authenticated users (from examples pages into captcha admin section, the behavior is the same) nor anonymous ones.
are there related error messages in the drupal log, webserver log or php log?
No errors in drupal log (it's written that image_captcha.js has been processed). I cannot investigate further into webserver/php log...
do you have a uid=0 in your users table? (which is common source for problems in CAPTCHA 5.x-3.x and 6.x-1.x, see http://drupal.org/project/issues/search/captcha?issue_tags=captchauid0)
Yes, uid 0 is there.
#30
Subscribing
#31
I have Two sites running with almost same modules installed but image captcha is working fine with one (image is displaying) but not with other.
What might be the reason ,I am not having any possible reason to explain my client (no version compatibility excuses) because it is running with one perfectly.
Plz help, very urgent !!!!!!!!!!
#32
at vijayitsoft: does CAPTCHA 6.x-2.x work? does the simple math challenge work on both sites?
your problem is probably cookies: are the cookie domains correct for both sites?
#33
it can be fuzzy but now works, latest actions:
clear all caches
http://pshahmumbai.wordpress.com/2009/08/09/clear-drupal-caches/
make and run from root a php file using this code
<?phpinclude_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_flush_all_caches();
install latest captcha-6.x-2.0-rc3 but remove the additional space at the end of captcha.inc file
try that in other modules too if you still cannot get the images...
if this is the issue, someone could write a global core patch or a module to check those (*.module, *.inc) files for spaces and prevent this bug in general...
#34
I am experiencing the same problem and none of solutions above worked for me.
I have uid=0 in users table, I switched page compression off, flushed cache, and still no progress.
Math captcha works, but there is no captcha image for anonymous users. Strange thing, on administration page I have a perfectly looking image captcha example.
Please, let me know which informations are needed to solve this problem?
Thanks a lot
#35
at jennalexx in #33: why do you suggest to remove additional space at the end of captcha.inc and other files? What would this be good for? One thing that can break image captcha is a closing
?>delimiter followed by whitespace at the end of a module or include file. But captcha.inc does not have a closing?>delimiter, as most drupal module and include files, so there is no problem here.at timurek in #34: when you say math captcha works, does this just mean that it shows a challenge, or does it mean that it also correctly blocks wrong answers and accepts right answers? Other interesting info: look at the markup code and report how an captcha image url looks like, try to load a captcha image url directly and report what you get (nothing, error message, an unreadable file, ...) also try different browsers for this.
#36
#35: Match CAPTCHA shows challenge, but also blocks when wrong answer is entered. I use it as well as other types of captchas from captcha pack :)
Image captcha: As anonymous user, when I try to access image captcha file directly, i got nothing:
http://www.vypocetni.technika.cz/image_captcha/%252F1252081547
But (working) image in administration module has another type of URL:
http://www.vypocetni.technika.cz/image_captcha/784/1252081520
Is it not strange? Especially the %252F part?
Issue appears in any browser I tried - IE, Opera, Firefox.
Thanks for taking care of it.
#37
At #36: see #431672: Image does not show in image_captcha when using random_captcha_type, the problem is in CAPTCHA pack, you should update to a version after 19 august, like 6.x-1.x-dev or 6.x-1.0-beta3
#38
Works, thanks a lot!
#39
I was having a very similar problem. I had the latest official release of CAPTCHA installed (6.x-2.0) in sites/all/modules of a multi-site installation. And Image CAPTCHA was working fine on every site but one. I tried every solution above, with no luck. So I downloaded the 6.x-2.0-dev version, thinking it was worth a try. I opened up the install file just to see if it was going to require a database update, and that prompted me to check the schema version for CAPTCHA in the systems table of the recalcitrant site. Ah hah. Turns out that, while I had the latest official release installed on that site, I hadn't run the updates on that site (as I had on all the others). I ran the updates, and bingo, it worked.
I did end up installing the dev version of the module as a result of the update (I had put it in sites/recalcitrant.site/modules/captcha_2, but apparently Drupal looks at the info file not the folder name). However, I am pretty sure that it was the database update and not the new code that fixed it, since that had been the ONLY difference between this site and the other sites that were functioning properly.