Question

I am using the Codeigniter captcha helper for the first time and I'd like to modify the colors that the helper has defined in RGB in a variable, for example there is:

$bg_color = imagecolorallocate ($im, 255, 255, 255);
$border_color = imagecolorallocate ($im, 153, 102, 102);
$text_color = imagecolorallocate ($im, 204, 153, 153);
$grid_color = imagecolorallocate($im, 255, 182, 182);
$shadow_color = imagecolorallocate($im, 255, 240, 240);

I've seen people saying to create a helper file in your custom helpers directory but I don't see how that would help here since I don't want to extend the helper, I want to sort override these variables.

So what is the best way to do this?

Was it helpful?

Solution

The reason you want to extend it is so you can "override" the "create_captcha" function without altering the original helper in your CI system folder. Your CI system should stay untouched so that it's easier for you to update CI on future versions. Also, if something goes wrong in your extended code, you can easily revert back to the original.

  1. So create a blank file application/helpers/MY_captcha_helper.php
  2. Copy only the create_captcha function from system/helpers/captcha_helper.php and paste into MY_captcha_helper.php.
  3. Make the changes to those RGB values you want in MY_captcha_helper.php.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top