更改yii中验证码图像的大小

更改yii中验证码图像的大小,yii,Yii,我想更改yii中验证码图像的大小。我知道宽度最初设置为100。我想把它扩大一倍。我无法使用以下代码更改任何内容 <?php $this->widget('CCaptcha',array('buttonOptions'=>array('style'=>'width:200'))); 如果要更改图像大小,则应使用图像选项而不是按钮选项,例如: <?php $this->widget('CCaptcha', array('imageOptions' =>

我想更改yii中验证码图像的大小。我知道宽度最初设置为100。我想把它扩大一倍。我无法使用以下代码更改任何内容

<?php $this->widget('CCaptcha',array('buttonOptions'=>array('style'=>'width:200'))); 

如果要更改图像大小,则应使用
图像选项
而不是
按钮选项
,例如:

<?php $this->widget('CCaptcha', array('imageOptions' => array('style'=>'width:20%'))); ?>


请看一下文档。

无需为图像元素设置样式,您就可以自然地实现这一点。在
SiteController
中,您有
actions()
方法,该方法返回
captcha
内置操作的一组选项

public function actions()
{
    return array(
        // captcha action renders the CAPTCHA image displayed on the contact page
        'captcha'=>array(
            'class'=>'CCaptchaAction',
            'backColor'=>0xFFFFFF,
            'width' => '..' // <- Set this to override a default width
        ),
public function actions()
{
返回数组(
//验证码动作呈现联系人页面上显示的验证码图像
“验证码”=>数组(
'class'=>'CCaptchaAction',
“背景色”=>0xFFFFFF,
“宽度”=>“…”//
是通过模板的解决方案 PHP:


只需抬起头,即可将图像拉伸到设定的大小
<?php $this->widget('CCaptcha'); ?>
        <?= $form->field($model, 'verifyCode')->widget(Captcha::className(), ['template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>']) ?>
    document.getElementById("reviews-verifycode-image").style.height = "100px";