您好,
我想在联系表单上更改验证码的布局。我需要减少其中包含的线条和点的数量,以便用户可以更清楚地看到文本。
有谁知道如何做吗?
提前致谢。
                  检查了吗?magecomp.com/magento-new-recaptcha.html
                
                
                  
                    —
                    Gaurav Jain 
                    
                  
                
              您好,
我想在联系表单上更改验证码的布局。我需要减少其中包含的线条和点的数量,以便用户可以更清楚地看到文本。
有谁知道如何做吗?
提前致谢。
Answers:
您上面回答的方法不是一个好的方法。
该类Zend_Captcha_Image提供了用于更改变量的函数。您可以在同一类中找到函数,如下所示:
public function setDotNoiseLevel ($dotNoiseLevel)
{
    $this->_dotNoiseLevel = $dotNoiseLevel;
    return $this;
}
/**
 * @param int $lineNoiseLevel
 */
public function setLineNoiseLevel ($lineNoiseLevel)
{
    $this->_lineNoiseLevel = $lineNoiseLevel;
    return $this;
}
并且还Zend_Captcha_Image扩展到Mage模型类,即Mage_Captcha_Model_Zend。因此,您可以轻松覆盖此Mage模型类以设置这些变量。
public function __construct($params)
{
    if (!isset($params['formId'])) {
        throw new Exception('formId is mandatory');
    }
    $this->_formId = $params['formId'];
    $this->setExpiration($this->getTimeout());
    $this->setDotNoiseLevel(10);     // Added code
    $this->setLineNoiseLevel(0);     // Added code
}
我在构造函数中设置了这些变量,以便即使页面加载和验证码刷新也可以使用更改。
如果您覆盖上述功能,而不是修改法师核心文件,将会更好。
您可以使用以下代码更改验证码噪声。
去 : lib/Zend/Captcha/Image.php
根据您的要求更改为可变值以下
protected $_dotNoiseLevel = 10; // Increase the value if you want to increase amount of dots
protected $_lineNoiseLevel = 0; // Increase the value if you want to increase amount of lines
参考:http : //magentoforall.blogspot.com.au/2012/11/magento-change-captcha-background-lines.html
对于Magento 2:转到vendor \ magento \ zendframework1 \ library \ Zend \ Captcha \ Image.php
您将在此文件中找到以下功能,这些功能可用于自定义验证码图像。
     /**
     * Set dot noise level
     *
     * @param int $dotNoiseLevel
     * @return Zend_Captcha_Image
     */
    public function setDotNoiseLevel ($dotNoiseLevel)
    {
        $this->_dotNoiseLevel = $dotNoiseLevel;
        return $this;
    }
    /**
     * Set line noise level
     *
     * @param int $lineNoiseLevel
     * @return Zend_Captcha_Image
     */
    public function setLineNoiseLevel ($lineNoiseLevel)
    {
        $this->_lineNoiseLevel = $lineNoiseLevel;
        return $this;
    }
您可以从行号122和129更改此函数的值。
/**
 * Number of noise dots on image
 * Used twice - before and after transform
 *
 * @var int
 */
protected $_dotNoiseLevel = 100;
/**
 * Number of noise lines on image
 * Used twice - before and after transform
 *
 * @var int
 */
protected $_lineNoiseLevel = 5;