WordPress.org

Support

Support » Plugins and Hacks » [Plugin: Contact Form 7] CAPTCHA width fix

[Plugin: Contact Form 7] CAPTCHA width fix

  • apmuthu
    Member

    @apmuthu

    Really Simple CAPTCHA plugin that WPCF7 (v7.3.2.1) uses has a default char_length = 4 (no. of chars in CAPTCHA).

    The default width settings for small, medium and large are in modules/captcha.php lines 459-481:

    if ( $image_size = array_shift( $image_size_array ) ) {
    		preg_match( '%^size:([smlSML])$%', $image_size, $is_matches );
    		switch ( strtolower( $is_matches[1] ) ) {
    			case 's':
    				$op['img_size'] = array( 60, 20 );
    				$op['base'] = array( 6, 15 );
    				$op['font_size'] = 11;
    				$op['font_char_width'] = 13;
    				break;
    			case 'l':
    				$op['img_size'] = array( 84, 28 );
    				$op['base'] = array( 6, 20 );
    				$op['font_size'] = 17;
    				$op['font_char_width'] = 19;
    				break;
    			case 'm':
    			default:
    				$op['img_size'] = array( 72, 24 );
    				$op['base'] = array( 6, 18 );
    				$op['font_size'] = 14;
    				$op['font_char_width'] = 15;
    		}
    	}

    The $op(‘img_size’][0] values can be doubled to accomodate upto 8 chars for char_length by editing the really-simple-captcha.php (v1.5) at line 36 to override the captcha default of 4:
    $op['char_length'] = 6;

    http://wordpress.org/extend/plugins/contact-form-7/

Viewing 1 replies (of 1 total)
  • The line nos. remain the same in WPCF7 v7.3.3.1 as well.

    After Line 480, ie., after the closing brace of the switch statement, insert the following line:

    $op['img_size'] *= 2;

    Now we can have upto 8 characters in the CAPTCHA image at line 36 in really-simple-captcha.php (v1.5) file:
    $this->char_length = 6;

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Contact Form 7] CAPTCHA width fix’ is closed to new replies.