Events Made Easy › Forums › Generic › CAPTCHA image do not show – fix here available
Tagged: captcha
- This topic has 7 replies, 3 voices, and was last updated 4 years ago by
Franky.
-
AuthorPosts
-
Thu 19 Jul 2018 at 15:19 #58203
Anonymous
InactiveWhen I use placeholder #_CAPTCHA in reservation form, GD lib generate image, but image wont show in browser.
Please, fix it by code bellow.
To fix this bug, do this:
eme_functions.php
function eme_captcha_generate() {
…
// give image back
ob_clean(); // <—- BUG FIX
header (“Content-type: image/gif”);
imagegif($im);
imagedestroy($im);
exit;
}Thu 19 Jul 2018 at 22:55 #58204Franky
KeymasterWhy would ob_clean be needed there?
Fri 20 Jul 2018 at 10:02 #58205Anonymous
InactiveIn my case, if there is not ob_clean function, header or any other data are sent, before GD lib generate captcha image and source link has invalid content. Web browser show only small black square, no captcha code. Probably, there is some colision between this and other plugin.
Fri 20 Jul 2018 at 11:35 #58206Franky
KeymasterWell, I don’t use ob_start anywhere, so ob_clean is not something I’d need here as well.
Indeed either another plugin (or your theme with empty lines) might be responsible, and that should be corrected.Mon 6 Aug 2018 at 09:54 #58251Anonymous
InactiveSorry, error in my wordpress template.
response of server was:
77u/<image data>77u/ is UTF8 BOM identification.
I use czech language, edit some teplate files and save in format UTF8 with BOM!
To fix this I use Notepad++, choose menu-format-convert to UTF8 (without BOM)
In status bar of app was shown: ANSI as UTF8This working properly
Sun 5 Dec 2021 at 01:32 #63534Anonymous
InactiveI had to insert the ob_clean to have the captcha displayed.
If I call directly the
[URL]/?eme_captcha=generate&f=49a075d52a3fb455454ff957861c54511a3e5392587712&ts=1638664168I receive a 0x0 gif image when I dont use the ob_clean
How to find where the incorrect char (or blank line) is added?
Thanks,
StephanSun 5 Dec 2021 at 13:35 #63535Anonymous
InactiveOK, I found my problem:
Analysing the GIF returned by the script, I saw the GIF begin with “\xef bb bf”, the gif should begin with “GIF”. So there are 3 hex chars before the file.
This is the BOM encoding for UTF8, it means that a file is encoded in “UTF8 with BOM”.Searched through all my files with
grep -R $’\UFEFF’ | grep phpThe wp-config.php was the culprit. Problem solved.
Ref: https://www.herongyang.com/Unicode/Notepad-Byte-Order-Mark-BOM-FEFF-EFBBBF.htmlSun 5 Dec 2021 at 13:37 #63536Franky
KeymasterYes, I make sure the theme isn’t responsible for captcha generation errors, but if the issue was in wp-config.php then many things that create images on the fly would not have worked.
-
AuthorPosts
- The forum ‘Generic’ is closed to new topics and replies.