4

I'm new in magento. I am working in custom module.

I apply captcha in registration page and login page. But, there are too much dots and lines display in image. Sometimes, I can't read text properly.

I checked in admin configuration. But, I didn't found any configuration to decrease dots and lines from CAPTCHA.

How to do manage this?

please help me to solve this issue.

Thanks.

2

Go to :

/vendor/magento/zendframework1/library/Zend/Captcha/Image.php

Open this file and go to line no 121 and 129.

Find this below line :

protected $_dotNoiseLevel = 100; // For dots
protected $_lineNoiseLevel = 5; // For lines

And replace it :

protected $_dotNoiseLevel = 50;
protected $_lineNoiseLevel = 3;

Save it and clean cache.

0

Tested in Magento 2.2
The DotNoiseLevel and LineNoiseLevel are set in vendor\zendframework\zend-captcha\src\Image.php You can override Magento\Captcha\Model\DefaultModel and set DotNoiseLevel and LineNoiseLevel as class DefaultModel extends \Zend\Captcha\Image

Your Custom module di.xml will be

<preference for="Magento\Captcha\Model\DefaultModel" type="Custom\Captcha\Model\DefaultModel"/>

and model class will be Custom\Captcha\Model\DefaultModel.php

public function __construct(
    \Magento\Framework\Session\SessionManagerInterface $session,
    \Magento\Captcha\Helper\Data $captchaData,
    \Magento\Captcha\Model\ResourceModel\LogFactory $resLogFactory,
    $formId
) {
    parent::__construct($session,$captchaData,$resLogFactory,$formId);
    $this->setDotNoiseLevel(2);
    $this->setLineNoiseLevel(1);
}
0

/vendor/magento/zendframework1/library/Zend/Captcha/Image.php (nothing will happen after change so go below path)

/vendor/zendframework/zend-captcha/src/Image.php

Open this file and go to line no 106 and 114.

Find this below line :

protected $_dotNoiseLevel = 100; // For dots protected $_lineNoiseLevel = 5; // For lines And replace it :

protected $_dotNoiseLevel = 0; protected $_lineNoiseLevel = 0;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.