更改 Zend 图像验证码样式
我有一个 Zend 形式的图像验证码,
$captcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => array(
'captcha' => 'Image',
'label' => 'Rasmdagi belgilarni kiriting',
'required' => true,
'wordLen' => 5,
'width' => 150,
'height' => 40,
'timeout' => 300,
'fontSize' => 32,
'gcFreq' => 5,
'font' => 'files/captcha/fonts/4.ttf',
'imgDir' => 'files/captcha/image',
'imgUrl' => '/files/captcha/image',
)));
$captcha->setIgnore(true);
我必须更改它的样式(背景)。
I have a image captcha in Zend form
$captcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => array(
'captcha' => 'Image',
'label' => 'Rasmdagi belgilarni kiriting',
'required' => true,
'wordLen' => 5,
'width' => 150,
'height' => 40,
'timeout' => 300,
'fontSize' => 32,
'gcFreq' => 5,
'font' => 'files/captcha/fonts/4.ttf',
'imgDir' => 'files/captcha/image',
'imgUrl' => '/files/captcha/image',
)));
$captcha->setIgnore(true);
I must change it's style(background).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信你不能改变验证码图像的背景。它被硬编码到
Zend_Captcha_Image
中。您必须通过扩展Zend_Captcha_Image
并修改图像设置背景的线条来创建自己的验证码图像类,例如My_Captcha_Image
。I believe that you cannot change the background of captcha image. It is hard coded into
Zend_Captcha_Image
. You would have to create your own captcha image class, e.g.My_Captcha_Image
by extendingZend_Captcha_Image
and amending the line/lines the setup background for the image.是的,背景颜色是硬编码在核心上的,但您仍然可以更改它!
只需在核心文件中搜索函数 _generateImage 并更改背景的创建方式即可
,例如:
要更改背景颜色,请更改线条:
和
Yes the background color is hardcoded on the core, but still you can change it!
Just search for the function _generateImage inside the core files and change how the background is created
Ex.:
To change the background color change the lines:
And